Exemple #1
0
        echo $token . "<br/>";
        //Format the token in the way ODataService Expects
        $authHeaderValue = 'WRAP access_token="' . urldecode($token) . '"';
        //Add the acs auth header
        $httpRequest->Headers->Add('authorization', $authHeaderValue);
    } catch (ACSUtilException $ex) {
        echo 'Failed to get the ACS token' . "<br/>";
        echo $ex->getError();
        exit;
    }
}
try {
    $svc = new NorthwindEntities1(ACS_NORTHWIND_SERVICE_URL);
    //Regitser the call-back
    $svc->OnBeforeRequest('OnBeforeCallBack', null);
    $query = $svc->Customers()->filter("CustomerID eq 'ALFKI'");
    $customersResponse = $query->Execute();
    if (count($customersResponse->Result)) {
        echo "<br/><br/>Customer Information <br/><br/>";
        $customer = $customersResponse->Result[0];
        echo 'CustomerID: ' . $customer->CustomerID . "<br/>";
        echo 'CompanyName: ' . $customer->CompanyName . "<br/>";
        echo 'ContactName: ' . $customer->ContactName . "<br/>";
        echo 'ContactTitle: ' . $customer->ContactTitle . "<br/>";
    } else {
        echo 'Failed to retrieve the Customer with ID \'ALFKI\'';
    }
} catch (DataServiceRequestException $ex) {
    echo 'Error: while running the query ' . $ex->Response->getQuery();
    echo "<br/>";
    echo $ex->Response->getError();