Wednesday, January 16, 2019

PHP Toolkit 2012.2 Sample Code: getDataCenterUrls

Ability to retrieve the datacenter URLs for the account specified in the NSConfig.php file using PHP Toolkit 2012.2.

Note: This article requires existing knowledge of Web Services and PHP.


Below is sample code for a getDataCenterUrls request.  The sample code also updates the endpoint in the NetSuiteService object if successful.

require_once '../PHPToolkit/NetSuiteService.php';

$service = new NetSuiteService();

$request = new GetDataCenterUrlsRequest();
$request->account = $nsaccount;
$Response = $service->getDataCenterUrls($request);

if (!$Response->getDataCenterUrlsResult->status->isSuccess) {
    echo "ERROR - " . $Response->getDataCenterUrlsResult->status->statusDetail[0]->code 
    . $Response->getDataCenterUrlsResult->status->statusDetail[0]->message;
} else {
    echo " SUCCESS " . $Response->getDataCenterUrlsResult->dataCenterUrls->webservicesDomain;
    $nshost = $Response->getDataCenterUrlsResult->dataCenterUrls->webservicesDomain; //Set the datacenter endpoint in the $nshost object
    $service = new NetSuiteService();  //Recreate the service using the new endpoint
}

// Additional code...

No comments:

Post a Comment