function ebay_upload_picture($name, $blob) { global $service, $token; $request = new Types\UploadSiteHostedPicturesRequestType(); $request->RequesterCredentials = new Types\CustomSecurityHeaderType(); $request->RequesterCredentials->eBayAuthToken = $token; $request->PictureName = $name; file_put_contents('d:/photo/test.jpg', $blob); $request->attachment(file_get_contents('d:/photo/test.jpg'), 'image/jpeg'); $response = $service->uploadSiteHostedPictures($request); if ($response->Ack !== 'Failure') { return $response->SiteHostedPictureDetails->FullURL; } if (isset($response->Errors)) { print "<pre>"; foreach ($response->Errors as $error) { printf("%s: %s\n%s\n\n", $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', $error->ShortMessage, $error->LongMessage); } die("Error uploading pictures."); } }
* An user token is required when using the Trading service. * * For more information about getting your user tokens, see: * http://devbay.net/sdk/guides/application-keys/ */ $request->RequesterCredentials = new Types\CustomSecurityHeaderType(); $request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken']; /** * Give the picture a name. */ $request->PictureName = 'Example'; /** * Attach the picture that we want to upload. * Specifying the mime type is optional. Defaults to application/octet-stream if none is provided. */ $request->attachment(file_get_contents(__DIR__ . '/picture.jpg'), 'image/jpeg'); /** * Send the request to the UploadSiteHostedPictures service operation. * * For more information about calling a service operation, see: * http://devbay.net/sdk/guides/getting-started/#service-operation */ $response = $service->uploadSiteHostedPictures($request); /** * Output the result of calling the service operation. * * For more information about working with the service response object, see: * http://devbay.net/sdk/guides/getting-started/#response-object */ if (isset($response->Errors)) { foreach ($response->Errors as $error) {