【发布时间】:2017-05-02 15:31:47
【问题描述】:
我正在调用与 Postman 一起正常工作的 API,但显示 PHP CURL“无效请求”的错误。我使用了以下代码。
$postData = array(
'oauth_consumer_key' => 'XXXXXXXXXXXXXXXXXXXXXX',
'oauth_token' =>'',
'oauth_signature_method' => 'PLAINTEXT',
'oauth_timestamp' =>time(),
'oauth_nonce' =>'DQp8tIsd',
'oauth_version' =>'1.0',
'oauth_signature' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'
);
$url = 'https://api.sandboxcernercare.com/oauth/access';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-
form-urlencoded'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
echo "<pre>";
print_r($result);
【问题讨论】: