PHP code example of justbetter / odata-client
1. Go to this page and download the library: Download justbetter/odata-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
justbetter / odata-client example snippets
aintSystems\OData\ODataClient;
class UsageExample
{
public function __construct()
{
$odataServiceUrl = 'https://services.odata.org/V4/TripPinService';
$odataClient = new ODataClient($odataServiceUrl);
// Retrieve all entities from the "People" Entity Set
$people = $odataClient->from('People')->get();
// Or retrieve a specific entity by the Entity ID/Key
try {
$person = $odataClient->from('People')->find('russellwhyte');
echo "Hello, I am $person->FirstName ";
} catch (Exception $e) {
echo $e->getMessage();
}
// Want to only select a few properties/columns?
$people = $odataClient->from('People')->select('FirstName','LastName')->get();
}
}
$example = new UsageExample();