プロジェクトに eBay API を統合しようとしています。ZendFramework を使用しており、eBay FindingAPI 用のライブラリがありますが、メソッドでは機能しませんfindItemsByProduct
。
問題を理解するために、私は小さなクラスを書きました:
<?php
class MyProject_Model_Ebay
{
const FINDING_API_URL = 'http://svcs.ebay.com/services/search/FindingService/v1?';
private $appId;
public function __construct($appId)
{
$this->appId = $appId;
}
public function findByProduct($id, $type = 'UPC')
{
$params = array(
'productId.@type' => $type,
'productId' => $id,
);
return $this->doApiRequest('findItemsByProduct', $params);
}
public function findByKeywords($keywords)
{
$params = array(
'keywords' => $keywords,
);
return $this->doApiRequest('findItemsByKeywords', $params);
}
private function doApiRequest($operationName, $payload)
{
$global = array(
'OPERATION-NAME' => $operationName,
'SECURITY-APPNAME' => $this->appId,
'GLOBAL-ID' => 'EBAY-US',
'SERVICE-VERSION' => '1.0.0',
'MESSAGE-ENCODING' => 'UTF-8',
'RESPONSE-DATA-FORMAT' => 'JSON',
);
$ret = file_get_contents(
self::FINDING_API_URL . http_build_query($global) . '&REST-PAYLOAD&' . http_build_query($payload)
);
return $ret;
}
}
メソッドは正常findItemsByKeywords
に動作しますが、findItemsByProduct
それでもエラーが返されます
商品 ID の値が無効です。
値を渡すさまざまなバリエーションを試しましたが、機能しません:(ここで見た値を渡す現在のバージョン: how to use python xml.etree.ElementTree to parse eBay API response?
使用法:
<?php
$eBay = new MyProject_Model_Ebay(
'My-app-id'
);
$eBay->findByProduct('4719331316129');
応答:
{"findItemsByProductResponse":[{"ack":["Failure"],"errorMessage":[{"error":[{"errorId":["41"],"domain":["Marketplace"],"severity":["Error"],"category":["Request"],"message":["Invalid product ID value."],"subdomain":["Search"],"parameter":["4719331316129"]}]}],"version":["1.11.1"],"timestamp":["2012-03-14T06:41:42.600Z"]}]}
重要!たとえば、EBAY-DE で GLOBAL-ID を変更すれば、すべて OK です。EBAY-US の何が問題なのですか?!