2

我正在尝试使用 CURL i PHP 发布到沃尔玛卖家 API 以确认订单。

https://developer.walmartapis.com/#acknowledgeing-purchase-orders

由于某种原因,它不会接受我的方法或返回“错误请求”。

有这方面经验的人吗?

$apiheaders = array(
'WM_SVC.NAME: Walmart Marketplace',
'WM_QOS.CORRELATION_ID: 1466113345',
'WM_SEC.TIMESTAMP:1466113345447',
'WM_SEC.AUTH_SIGNATURE: XXXXXXXXXXX'
'WM_CONSUMER.ID: XXXXXXXXXXX',
'Content-Type: application/xml',
'Accept: application/xml',
 );

$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $apiheaders);
curl_setopt($curl, CURLOPT_URL,$return_api_host);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
$response = curl_exec($curl);
curl_close($curl);
4

2 回答 2

0
<?php
$consumer_id='xxxxxxxxxx';
$private_key='xxxxxxxxxx';
$timestamp='xxxxxxxx';
$correlation_id='xxxxxxxxxxx';
$channel_id='xxxxxxxxxx';

$endPoint = "v3/orders/".$purchaseOrderId."/acknowledge";
$requestUrl = "https://marketplace.walmartapis.com/$endPoint";
$requestMethod = 'POST';
$signature = new Signature($consumer_id, $private_key, $requestUrl,$requestMethod);
$actual_signature = $signature->getSignature($timestamp);

$headers = [];
$headers[] = "WM_SVC.NAME: Walmart Marketplace";
$headers[] = "WM_QOS.CORRELATION_ID: ".$correlation_id;
$headers[] = "WM_SEC.TIMESTAMP: ".$timestamp;
$headers[] = "WM_SEC.AUTH_SIGNATURE: ".$actual_signature;
$headers[] = "WM_CONSUMER.ID: " .$consumer_id;
$headers[] = "Content-Type: multipart/form-data";
$headers[] = "Accept: application/xml";
$headers[] = "WM_CONSUMER.CHANNEL.TYPE: ".$channel_id;
$headers[] = "HOST: marketplace.walmartapis.com";


$body['data'] = array();

$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $requestUrl );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_HEADER, 1 );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $body );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
$server_output = curl_exec ( $ch );
?>
于 2017-11-27T13:17:41.950 回答
0

就我而言,问题来自我的标题签名。此处未显示。不要忘记为正确的传输类型创建签名。例如 post、get 等。我在之前的调用中将其设置为 get 并且没有将其设置为应有的变量。

随时发布您的示例,以便我们查看。

于 2016-10-20T23:35:43.407 回答