以下是用Data Entities 拿取AX/D365 資料:
public static function getProducts(){
// initiaze curl which is used to make the http request.
$ch = curl_init();
// Add authorization and other headers. Also set some common settings.
AXAccessHelper::AddRequiredHeadersAndSettings($ch);
// set url
$odataURL = Settings::$appADResource.'/data/ReleasedDistinctProducts?$filter=dataAreaId%20eq%20\'USMF\'&cross-company=true';
curl_setopt($ch, CURLOPT_URL, $odataURL);
//Enable fiddler to capture request
//curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
$jsonOutput = json_decode($output);
// There is a field for odata metadata that we ignore and just consume the value
return $jsonOutput->{'value'};
}
以下是用custom services 拿取或是更改AX/D365 資料:
public static function getUserSessionInfo(){
// initiaze curl which is used to make the http request.
$ch = curl_init();
// Add authorization and other headers. Also set some common settings.
AXAccessHelper::AddRequiredHeadersAndSettings($ch);
// set url
$odataURL = Settings::$appADResource.'/api/services/UserSessionService/AifUserSessionService/GetUserSessionInfo';
curl_setopt($ch, CURLOPT_URL, $odataURL);
//Enable fiddler to capture request
//curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
$jsonOutput = json_decode($output);
return $jsonOutput;
}
留言列表