//我已经使用过这段代码但是返回空白以及要在$ data array中传递的数据。我在这里分享你们所有细节。 http://dev.hordanso.com:5050 商家= justenergy&安培;用户名= mogobahor&安培;密码= VerJust123&安培;方法= GetHistory
$method='POST';
$url='http://dev.hordanso.com:5050';
$data=array("headers"=>"GetHistory","Content-Type"=>"application/x-www-form-urlencoded","name"=>"JustEnergyAPI-AlphaBills","payload"=>"merchant=justenergy&method=GetNextPayment","kind"=>"ARC#RequestData");
CallAPI($method, $url, $data);
function CallAPI($method, $url, $data = false)
{
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "mogobahor:VerJust123");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
}
?>