【发布时间】:2014-04-10 03:24:43
【问题描述】:
大家好,我正在运行我自己的 PHP 服务器(通过 WAMP)并使用提供的 Walgreens API PHP 示例来测试上传的照片。
以下是我的一些似乎停止的代码:
$affiliateId = "xxxxx";
$apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$apiEndPoint = "https://services-qa.walgreens.com/api/util/mweb5url";
$cred_data = array(
"serviceType"=>"wagS3",
"act"=>"genCredV2",
"view"=>"genCredV2JSON",
"affId"=> $affiliateId,
"apiKey"=>$apiKey,
"devinf"=>"IE,11",
"appver"=>"0.01"
);
$cred_data=json_encode($cred_data);
echo "<br/>Credential Request = ",$cred_data;
$headers = array('Content-type: application/json; charset=utf-8');
$curl = curl_init($apiEndPoint);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $cred_data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$cred_response = curl_exec($curl);
echo "<br/>Credential Response = ",$cred_response,"<br/>";
$cred_response = json_decode($cred_response,TRUE);
curl_close($curl);
当我将它放到由托管公司托管的另一台服务器上并运行 php 文件时,它工作得很好(给出 echo "Credential Response = ",$cred_response,""; 一个实际的响应。)。
但是,当我在本地机器上运行代码时,它没有返回任何响应,例如被阻止或其他什么?
我从另一台服务器得到的响应是:
Credential Request = {"serviceType":"wagS3","act":"genCredV2","view":"genCredV2JSON","affId":"xxxxx","apiKey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx":"IE,11","appver":"0.01"}
Credential Response = {"uploadUrl":"http://xxxxxxxxxxxxx.com","secretKey":"xxxxxxxxxxxxxxxxxxxx","sessionId":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","err":"","accessKeyId":"xxxxxxxxxxxxxxxxxxxxxxxx"}
我从本地服务器得到的响应是:
Credential Request = {"serviceType":"wagS3","act":"genCredV2","view":"genCredV2JSON","affId":"xxxxx","apiKey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx":"IE,11","appver":"0.01"}
Credential Response =
我的 Apache 和/或 PHP 文件中是否缺少设置或插件?
【问题讨论】:
标签: php api curl wamp wampserver