我向ebay发送xml请求,但它没有回复任何内容。我检查了每个字段,如runame,header和curl,但似乎仍然没有任何错误。任何人都可以解决这个问题吗?
$runame = "Th_c_L__B_-ThcLB-SynEbay-S-swfednxx";
$xml = '<?xml version="1.0" encoding="utf-8"?>'.
'<GetSessionIDRequest xmlns="urn:ebay:apis:eBLBaseComponents">'.
'<RuName>'.$runame.'</RuName>'.
'</GetSessionIDRequest>';
$headers = array(
'Content-Type' => 'text/xml',
'X-EBAY-API-COMPATIBILITY-LEVEL' => '889',
'X-EBAY-API-DEV-NAME' => $devId,
'X-EBAY-API-APP-NAME' => $appId,
'X-EBAY-API-CERT-NAME' => $certId,
'X-EBAY-API-SITEID' => '0',
'X-EBAY-API-CALL-NAME' => 'GetSessionID'
);
$url = 'https://api.sandbox.ebay.com/ws/api.dll';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_TIMEOUT, 400);
$result = curl_exec($ch);
curl_close($ch);
echo '<pre>';
print_r($result);
echo '</pre>';
答案 0 :(得分:0)
我自己发现需要将CURLOPT_SSL_VERIFYPEER设置为false,因为Ebay需要https并且我在localhost中运行它,它没有SSL认证。另外,$ headers数组绝不能使用关联。
$runame = "Th_c_L__B_-ThcLB-SynEbay-S-swfednxx";
$xml = '<?xml version="1.0" encoding="utf-8"?>'.
'<GetSessionIDRequest xmlns="urn:ebay:apis:eBLBaseComponents">'.
'<RuName>'.$runame.'</RuName>'.
'</GetSessionIDRequest>';
$headers = array(
'Content-Type: text/xml',
'X-EBAY-API-COMPATIBILITY-LEVEL: 911',
'X-EBAY-API-DEV-NAME: ' . $this->devId,
'X-EBAY-API-APP-NAME: ' . $this->appId,
'X-EBAY-API-CERT-NAME: '. $this->certId,
'X-EBAY-API-SITEID: 0',
'X-EBAY-API-CALL-NAME: GetSessionID'
);
$url = 'https://api.sandbox.ebay.com/ws/api.dll';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_TIMEOUT, 400);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($ch);
curl_close($ch);
echo '<pre>';
print_r($result);
echo '</pre>';