Hi guys :) I am trying to take all meeting from resource meeting box, but when i try to take subject like this $subject = $event->Subject it displays name by whom meeting was created. $request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = "mail#domain.com" This is code how i select resource meeting box.
I want to take meeting subject by other way and i will be glad if you will help me :)
$request = new EWSType_FindItemType();
// Use this to search only the items in the parent directory in question or use ::SOFT_DELETED
// to identify "soft deleted" items, i.e. not visible and not in the trash can.
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
// This identifies the set of properties to return in an item or folder response
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
// Define the timeframe to load calendar items
$request->CalendarView = new EWSType_CalendarViewType();
$request->CalendarView->StartDate ='2014-03-28T15:00:00+04:00';// an ISO8601 date e.g. 2012-06-12T15:18:34+03:00 "Y-m-d\TH:i:sO"
$request->CalendarView->EndDate = '2015-03-28T15:00:00+04:00';// an ISO8601 date later than the above "Y-m-d\TH:i:sO"
// Only look in the "calendars folder"
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = "meetingroom#gcfund.ge";
// Send request
$response = $ews->FindItem($request);
// Loop through each item if event(s) were found in the timeframe specified
if ($response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView > 0){
$events = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem;
// $db_selected = mysql_select_db('meeting_room',$con);
// $res=mysql_query("SELECT ID FROM meeting");
// while($row = mysql_fetch_array($res)){
// echo $row['ID'];
// echo "<br>";
// }
foreach ($events as $event){
$id = $event->ItemId->Id;
$change_key = $event->ItemId->ChangeKey;
$start = $event->Start;
$end = $event->End;
$subject = $event->Subject;
$location = $event->Location;
This subject displays by whom meeting was created. I want this info too but i want Subject too.. Please Help :)
This is an issue with Exchange (not your code, or the PHP library, or EWS)
Several blogs, such as this one: http://www.slipstick.com/exchange/cmdlets/meeting-organizers-name-appears-in-subject-line/ indicate that you can perform some PowerShell commands to change the Exchange server configuration. Note that if you change the configuration, it will apply for all new meetings/appointments added after the configuration change (existing meetings/appointments will stay as-is).
If you don't have PowerShell access to the Exchange server but do have administrator access via another system, you might be able to achieve the same configuration change through the interface for that system. For example, on a Parallels hosted exchange system, login to Parallels as administrator, go to Exchange, go to Resource mailboxes, edit the room resource, and untick the "Add organizer to subject" checkbox under the "Resource scheduling" tab. As far as I can tell, this just performs the same PowerShell action behind the scenes.
There may be similar options in other systems (e.g. Office 365) though I haven't looked into that.
Having said all that, I have found that making this configuration change didn't help in my case: I created a new meeting against a room resource, however the subject ended up as "" (empty string) instead of the correct subject or the organiser's name. In any case, give the configuration change a try, as other people have apparently had success with it.
Related
This is my second day messing with the PHP SDK, I've encountered a road block with uploading an attachment to an Estimate with my code. I wanted a PHP form where one can upload a file and shoot it into the QBO company; my first step was to first try and set a static variable to see if it works, my code look slike this:
$Estimate = $dataService->query("SELECT * FROM Estimate WHERE DocNumber in ('{$ID}')");
// Create a new IPPAttachable
$up = "http://www.somedomain.com/test.pdf";
$sendMimeType = "application/pdf";
$randId = rand();
$entityRef = new IPPReferenceType($Estimate->Id);
$attachableRef = new IPPAttachableRef($entityRef);
$objAttachable = new IPPAttachable();
$objAttachable->FileName = $randId."TEST02.pdf";
//$objAttachable->AttachableRef = $Estimate->DocNumber;
$objAttachable->AttachableRef = $attachableRef;
$objAttachable->Note = "Test";
$objAttachable->ContentType = $sendMimeType;
$resultObj = $dataService->Upload($up,
$objAttachable->FileName,
$sendMimeType,
$objAttachable);
This code fires, adds an attachment to the proper estimate but the attachment is less than 1k and is unreadable. Almost as if it never fetched the document to attach, it simply made some kind of a "generic" success.
Can anyone assist with updating the above code? I'm sure its right in front of me, but I keep missing.
Thank you!
I am trying to add a contact in Exchange, using the php-ews and the following code:
$request = new EWSType_CreateItemType();
$request->SendMeetingInvitations = 'SendToNone';
$contact = new EWSType_ContactItemType();
$contact->GivenName = $updates['name'];
$contact->Surname = $updates['surname'];
if($updates['email'] != ""){
$email = new EWSType_EmailAddressDictionaryEntryType();
$email->Key = new EWSType_EmailAddressKeyType();
$email->Key->_ = EWSType_EmailAddressKeyType::EMAIL_ADDRESS_1;
$email->_ = $updates['email'];
// set the email
$contact->EmailAddresses = new EWSType_EmailAddressDictionaryType();
$contact->EmailAddresses->Entry[] = $email;
}
$contact->CompanyName = $updates['companyname'];
$contact->JobTitle = $updates['jobtitle'];
$contact->Birthday = $updates['birthday'];
$request->Items->Contact[] = $contact;
$response = $this->ews->CreateItem($request);
Where $updates is an array of strings I have as a parameter.
(I skipped the includes, tell me if you need them.)
Now, the contact gets created and everything works, but the birthday event does not get created automatically in my calendar.
So, I would like to know if there's a simple way to have this done, except the obvious (non-elegant) way of creating it manually.
Thank you in advance,
Riccardo
Could solve this using DateTime in the right format as expected in the comments.
$contact->Birthday = (new DateTime($updates['birthday']))->format(DATE_W3C);
https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/time-zones-and-ews-in-exchange
The time zone specified in the value of dateTime elements can take three forms. You can read all the details in XML Schema Part 2: Datatypes Second Edition, but to paraphrase:
Universal Coordinated Time (UTC): Specified by 'Z'. For example, 2014-06-06T19:00:00.000Z
Specific time zone: Specified by '+' or '-' followed by hours and minutes. For example, 2014-06-06T19:00:00.000-08:00
No time zone: Specified by the absence of any time zone. For example, 2014-06-06T19:00:00.000
I have been searching for days for a working example! The Netsuite documentation is really poor. I don't know what exactly are the config parameters or where I can get them.
I'm recreating the get_customer example.
My code:
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$request = new GetRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = "21";
$request->baseRef->type = "customer";
$getResponse = $service->get($request);
if (!$getResponse->readResponse->status->isSuccess) {
echo "GET ERROR";
} else {
$customer = $getResponse->readResponse->record;
echo "GET SUCCESS, customer:";
echo "\nCompany name: ". $customer->companyName;
echo "\nInternal Id: ". $customer->internalId;
echo "\nEmail: ". $customer->email;
}
?>
This is the thrown error:
Webservice host must be specified in NSPHPClient->__construct()
How can I fix this?
To be clear, there should be a file in the same directory as NetSuiteService.php called NSconfig.php. You don't need to include this file in your script; it gets called from NSPHPClient.php. The default NSconfig.php looks like this:
$nsendpoint = "2013_2";
$nshost = "https://webservices.netsuite.com";
$nsemail = "jDoe#netsuite.com";
$nspassword = "mySecretPwd";
$nsrole = "3";
$nsaccount = "MYACCT1";
The nsendpoint and nshost should stay as they are.
The tricky part is getting the correct settings for the other variables. First off, you need to Set up Web Services (http://www.netsuite.com/portal/partners/integration/download/SuiteTalkWebServicesPlatformGuide_2012.2.pdf Starting at page 34), then you need to create a Web Services Role (page 44), and make sure that Role has the necessary permissions. Assign that Role to a user that also has the appropriate permissions, then...
nsemail = the email of the user with the web services role
nspassword = the password of the nsemail user
nsrole = the internal role id of the web services role
nsaccount = your netsuite account number (most likely six digits)
(for info on seeing your internal role ids, see page 20 of the PDF above.)
Make sure that you have included the NSconfig.php file. Also you need to modify this file with your account credentials
I'm in the process of writing some code that will submit an order to Paypal Express Checkout. Unforunately I can't seem to get the whole address thing to work, and I also can't seem to find much info on it in the API docs. Here's my code so far.
$config = array (
'mode' => 'sandbox' ,
'acct1.UserName' => '****removed*****',
'acct1.Password' => '******removed*******',
'acct1.Signature' => '*********removed***********'
);
$paypalService = new PayPal\Service\PayPalAPIInterfaceServiceService($config);
$paymentDetails= new PayPal\EBLBaseComponents\PaymentDetailsType();
// Dummy shipping address
// Obviously, in the final version, this would be passed in from a form
$shipping_address = new PayPal\EBLBaseComponents\AddressType();
$shipping_address->Name = "John Smith";
$shipping_address->Street1 = "123 Market Street";
$shipping_address->Street2 = "";
$shipping_address->CityName = "Columbus";
$shipping_address->StateOrProvince = "OH";
$shipping_address->PostalCode = "43017";
$shipping_address->Country = "US";
// A dummy item
// Once again, in a final version this would be passed in
$itemDetails = new PayPal\EBLBaseComponents\PaymentDetailsItemType();
$itemDetails->Name = 'Electro Lettuce Feeders';
$itemAmount = 1250.00;
$itemDetails->Amount = $itemAmount;
$itemQuantity = 1;
$itemDetails->Quantity = $itemQuantity;
// Add all items to the list
$paymentDetails->PaymentDetailsItem[0] = $itemDetails;
// The company is in NYS, so in the final version the
// sales tax rate will be passed in (NYS is destination-based)
$sales_tax_rate = 0.07;
// Order sub-total
$itemTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$itemTotal->currencyID = 'USD';
$itemTotal->value = ($itemAmount * $itemQuantity);
// Shipping total
$shippingTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$shippingTotal->currencyID = 'USD';
$shippingTotal->value = 2.00;
// Tax total
$taxTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$taxTotal->currencyID = 'USD';
$taxTotal->value = $itemTotal->value * $sales_tax_rate;
// Order total
$orderTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$orderTotal->currencyID = 'USD';
$orderTotal->value = $itemTotal->value + $taxTotal->value + $shippingTotal->value;
$paymentDetails->TaxTotal = $taxTotal;
$paymentDetails->ItemTotal = $itemTotal;
$paymentDetails->ShippingTotal = $shippingTotal;
$paymentDetails->OrderTotal = $orderTotal;
$paymentDetails->PaymentAction = 'Sale';
// ***** Is the address from this object passed to Paypal?
$paymentDetails->ShipToAddress = $shipping_address;
$setECReqDetails = new PayPal\EBLBaseComponents\SetExpressCheckoutRequestDetailsType();
$setECReqDetails->PaymentDetails[0] = $paymentDetails;
$setECReqDetails->CancelURL = 'https://devtools-paypal.com/guide/expresscheckout/php?cancel=true';
$setECReqDetails->ReturnURL = 'https://devtools-paypal.com/guide/expresscheckout/php?success=true';
// ***** Or is this the address that will be passed to Paypal?
$setECReqDetails->Address = $shipping_address;
// ***** And can you choose to not pass in the billing address? Or is it required? *****
$setECReqDetails->BillingAddress = $shipping_address;
// ***** If this is set to 0, will the previously provided shipping address be shown
// ***** at all? Or will it just be "modify-able" unless you set this to 1?
$setECReqDetails->AddressOverride = 1;
$setECReqType = new PayPal\PayPalAPI\SetExpressCheckoutRequestType();
$setECReqType->Version = '104.0';
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
$setECReq = new PayPal\PayPalAPI\SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
//var_dump($setECResponse);
$redirect_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=".$setECResponse->Token;
return $app->redirect($redirect_url);
Summed up...
You'll see my questions distributed throughout the code, but here they are all summed up.
Both PaymentDetailsType() and SetExpressCheckoutRequestType() have address-ish properties. Which one will be passed on to Paypal?
Does the API require that you pass in a billing address if you pass in a shipping address?
If you don't set AddressOverride to 1, should it show the address that you passed in at all?
But in the end, I most importantly just want to know how to get address passing to work. =). Right now I can't seem to get any address to pass to Paypal no matter what I try.
It would help more to see the raw API requests getting generated as opposed to the code generating the requests. The library you're using should give you some way to see that. Then you just need to make sure the address parameters are getting passed correctly in DoExpressCheckoutPayment.
If you like, you might want to take a look at my PHP class library for PayPal. Might kinda suck to start over with another library, but it makes it very quick and easy. It has files prepared with all the parameters and everything ready to go so all you need to do is fill in the values and it'll work every time. :)
After some furious research, I was able to figure out the problem using Paypal's API explorer. As it turns out, setting ->Address on the SetExpressCheckoutRequestType() object is deprecated. The correct method is to set ->ShipToAddress for your PaymentDetailsType() object.
In my case, however, the reason that nothing was working was because I had my address wrong [slaps palm into forehead]. My zip, while in the region of Columbus, OH is technically in Dublin, OH. So, Paypal was generating an error.
Paypal wasn't showing me error information, however, so I had no way to know what in particular was causing the error. This is where the API explorer came in handy; I filled in the API explorer and tried my request--and it gave me detailed error information.
Since then, I've also found out that I can see detailed error information simply by using:
var_dump($setECResponse);
As part of a PHP webapp I have MySQL contacts table. It is integrated throughout the app, allowing you add a contact, edit a contact or add a contact as a relation to another table. However, currently it is self-contained. The company would like it to sync with Exchange, so that contacts added to Exchange will show up on the webapp and contacts added on the webapp will show up through Exchange.
So I have two problems: 1) communicating with Exchange 2) syncing with Exchange.
As far as the basic communication goes, it looks like this library will be able to manage it https://github.com/jamesiarmes/php-ews. However, I am quite lost as to how to manage syncing and don't where to start.
The build-in way to sync items is via function called SyncFolderItems. Basically to Exchange everything, including contacts is a folder, so you'll just pass CONTACTS as DistinguishedFolderId in your sync request.
The sync works by donloading all the items for given account in batches of max 512 elements and after each batch it gives you SyncState as a refernce point for Exchange to know where you left off. So it gives you ability to do incremental sync.
Now, that's one way of course, meaning Exchange -> Your DB. The other way it aeound you should preform atomic updates/request - the moment you change/add/delete item form your db you should issue adequate request to Exchange server to keep data in sync, elese it'll be overwritten on your next SyncFolderItems.
You can read up more on SyncFolderItems # MSDN
If you'd like to see example of SyncFolderItems you can take a look # python version of EWSWrapper, it's been added in recently. Although it's python, you can still get the basic idea how to construct the request / handle response.
Hope this helps :)
I am aware that this topic is pretty old. However, for future reference find a solution below. It is using the above-mentioned library php-ews.
I have also just added this to the official php-ews wiki: https://github.com/jamesiarmes/php-ews/wiki/Calendar:-Synchronization
// Define EWS
$ews = new ExchangeWebServices($host, $username, $password, $version);
// fill with string from last sync
$sync_state = null;
$request = new EWSType_SyncFolderItemsType;
$request->SyncState = $sync_state;
$request->MaxChangesReturned = 512;
$request->ItemShape = new EWSType_ItemResponseShapeType;
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->SyncFolderId = new EWSType_NonEmptyArrayOfBaseFolderIdsType;
$request->SyncFolderId->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType;
$request->SyncFolderId->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$response = $ews->SyncFolderItems($request);
$sync_state = $response->ResponseMessages->SyncFolderItemsResponseMessage->SyncState;
$changes = $response->ResponseMessages->SyncFolderItemsResponseMessage->Changes;
// created events
if(property_exists($changes, 'Create')) {
foreach($changes->Create as $event) {
$id = $event->CalendarItem->ItemId->Id;
$change_key = $event->CalendarItem->ItemId->ChangeKey;
$start = $event->CalendarItem->Start;
$end = $event->CalendarItem->End;
$subject = $event->CalendarItem->Subject;
}
}
// updated events
if(property_exists($changes, 'Update')) {
foreach($changes->Update as $event) {
$id = $event->CalendarItem->ItemId->Id;
$change_key = $event->CalendarItem->ItemId->ChangeKey;
$start = $event->CalendarItem->Start;
$end = $event->CalendarItem->End;
$subject = $event->CalendarItem->Subject;
}
}
// deleted events
if(property_exists($changes, 'Delete')) {
foreach($changes->Delete as $event) {
$id = $event->CalendarItem->ItemId->Id;
$change_key = $event->CalendarItem->ItemId->ChangeKey;
$start = $event->CalendarItem->Start;
$end = $event->CalendarItem->End;
$subject = $event->CalendarItem->Subject;
}
}