You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -430,18 +430,18 @@ This function uses cURL to send the appropriate request to the specified endpoin
430
430
431
431
We can use this function to call any of Outlook REST APIs. Let's add a new function to the `OutlookService` class to get the user's 10 most recent messages from the inbox.
432
432
433
-
In order to call our new `makeApiCall` function, we need an access token, the user's email address, a method, a URL, and an optional payload. We already have the access token, and from the [Mail API Reference](https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#GetMessages), we know that the method to get messages is `GET` and that the URL to get messages is `https://outlook.office.com/api/v1.0/me/messages`. Using that information, add a `getMessages` function in `outlook.php`.
433
+
In order to call our new `makeApiCall` function, we need an access token, the user's email address, a method, a URL, and an optional payload. We already have the access token, and from the [Mail API Reference](https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#GetMessages), we know that the method to get messages is `GET` and that the URL to get messages is `https://outlook.office.com/api/v2.0/me/messages`. Using that information, add a `getMessages` function in `outlook.php`.
434
434
435
435
#### New `getMessages` function in `./outlook.php` ####
public static function getMessages($access_token, $user_email) {
440
440
$getMessagesParameters = array (
441
-
// Only return Subject, DateTimeReceived, and From fields
442
-
"\$select" => "Subject,DateTimeReceived,From",
443
-
// Sort by DateTimeReceived, newest first
444
-
"\$orderby" => "DateTimeReceived DESC",
441
+
// Only return Subject, ReceivedDateTime, and From fields
442
+
"\$select" => "Subject,ReceivedDateTime,From",
443
+
// Sort by ReceivedDateTime, newest first
444
+
"\$orderby" => "ReceivedDateTime DESC",
445
445
// Return at most 10 results
446
446
"\$top" => "10"
447
447
);
@@ -453,7 +453,7 @@ In order to call our new `makeApiCall` function, we need an access token, the us
453
453
454
454
The function uses OData query parameters to do the following.
455
455
456
-
- Request that only the `Subject`, `DateTimeReceived`, and `From` fields for each message be returned. It's always a good idea to limit your result set to only those fields that you will use in your app.
456
+
- Request that only the `Subject`, `ReceivedDateTime`, and `From` fields for each message be returned. It's always a good idea to limit your result set to only those fields that you will use in your app.
457
457
- Sort the results by date and time each message was received.
458
458
- Limit the results to the first 10 items.
459
459
@@ -541,7 +541,7 @@ Update `./home.php` one final time to generate the table.
0 commit comments