【发布时间】:2015-11-11 16:16:27
【问题描述】:
GET /post-order/v2/casemanagement/{caseId} 调用 eBay Post Order API,给出一个空字符串。谁能弄清楚我的代码哪里出错了?我是否正确传递了标题?尤其是授权的语法是否正确?
<?php
error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging
//Seller Authorization Token
$userAuthToken= 'Authorization:TOKEN abc123';
//Endpoint URL to Use
$url = "https://api.ebay.com/post-order/v2/casemanagement/xyz";
//Initializle cURL
$connection = curl_init();
//Set Endpoint URL
curl_setopt($connection,CURLOPT_URL,$url);
//Set HTTP Method
curl_setopt($connection, CURLOPT_HTTPGET, true);
//Create Array of Required Headers
$headers = array();
$headers[] = $userAuthToken;
$headers[] = 'Content-Type:application/json';
$headers[] = 'X-EBAY-C-MARKETPLACE-ID:EBAY-DE';
//var_dump($headers);
//set the headers using the array of headers
curl_setopt($connection,CURLOPT_HTTPHEADER,$headers);
//set it to return the transfer as a string from curl_exec
curl_setopt($connection,CURLOPT_RETURNTRANSFER,1);
//stop CURL from verifying the peer's certificate
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
//Execute the Request
$response = curl_exec($connection);
//close the connection
curl_close($connection);
var_dump($response);
【问题讨论】:
-
你找到解决问题的方法了吗,我也有同样的方法??问候
-
停止关闭 CURLOPT_SSL_VERIFYPEER 并修复您的 PHP 配置。任何运行最近的 Linux 发行版的人都可能已经好了,因为他们通过包管理器获得了 curl 库,并且最近的 curl 库附带了来自 Mozilla.org 的最新 CA 根证书包。这意味着您只需打开 CURLOPT_SSL_VERIFYPEER 就不会出现任何错误。
标签: php curl ebay-api php-curl