* The namespaces provided by the SDK. */ use DTS\eBaySDK\Constants; use DTS\eBaySDK\FileTransfer; use DTS\eBaySDK\BulkDataExchange; use DTS\eBaySDK\MerchantData; /** * Create the service objects. * * This example uses both the File Transfer and Bulk Data Exchange services. * * For more information about creating a service object, see: * http://devbay.net/sdk/guides/getting-started/#service-object */ $exchangeService = new BulkDataExchange\Services\BulkDataExchangeService(array('authToken' => $config['sandbox']['userToken'], 'sandbox' => true)); $transferService = new FileTransfer\Services\FileTransferService(array('authToken' => $config['sandbox']['userToken'], 'sandbox' => true)); $merchantDataService = new MerchantData\Services\MerchantDataService(); /** * Before anything can be uploaded a request needs to be made to obtain a job ID and file reference ID. * eBay needs to know the job type and a way to identify it. */ $createUploadJobRequest = new BulkDataExchange\Types\CreateUploadJobRequest(); $createUploadJobRequest->uploadJobType = 'ReviseInventoryStatus'; $createUploadJobRequest->UUID = uniqid(); /** * Send the request to the createUploadJob service operation. * * For more information about calling a service operation, see: * http://devbay.net/sdk/guides/getting-started/#service-operation */ print 'Requesting job Id from eBay...';
printf("%s: %s\n%s\n\n", $error->SeverityCode === Trading\Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', $error->ShortMessage, $error->LongMessage); } } if ($response->Ack !== 'Failure') { /** * Get the values that will be passed to the File Transfer service. */ $fileReferenceId = $response->FileReferenceID; $taskReferenceId = $response->TaskReferenceID; printf("FileReferenceID [%s] TaskReferenceID [%s]\n", $fileReferenceId, $taskReferenceId); print "Downloading file...\n"; /** * An user token is required when using the File Transfer service. * Note that unlike the Trading service this token is not passed in via the request object. */ $service = new FileTransfer\Services\FileTransferService(array('authToken' => $config['production']['userToken'])); $request = new FileTransfer\Types\DownloadFileRequest(); $request->fileReferenceId = $fileReferenceId; $request->taskReferenceId = $taskReferenceId; $response = $service->downloadFile($request); if (isset($response->errorMessage)) { foreach ($response->errorMessage->error as $error) { printf("%s: %s\n\n", $error->severity === FileTransfer\Enums\ErrorSeverity::C_ERROR ? 'Error' : 'Warning', $error->message); } } if ($response->ack !== 'Failure') { /** * Check that the response has an attachment. */ if ($response->hasAttachment()) { $attachment = $response->attachment();