-
Notifications
You must be signed in to change notification settings - Fork 109
Example Calls
Adam Anderly edited this page Feb 15, 2017
·
21 revisions
// Using the example OData service from odata.org
$odataServiceUrl = 'http://services.odata.org/V4/TripPinService';
$odataClient = new ODataClient($odataServiceUrl);
// Need to authenticate the requests to the service? Pass in a Closure as the second argument
// which will get passed the request object
// Access token retrieved from an oauth
$accessToken = 'abc';
$odataClient = new ODataClient($odataServiceUrl, function($request) {
$request->headers['Authorization'] = 'Bearer '.$accessToken;
});
// Retrieve all entities from the "People" Entity Set
$people = $odataClient->from('People')->get();
// Or retrieve a specific entity by the Entity ID/Key
$person = $odataClient->from('People')->find('russellwhyte');
echo "Hello, I am $person->FirstName ";