接口服务商:互亿无线(www.ihuyi.com)
--------------------------------------------------------------------------------------------------
$basicUrl ="http://f.ihuyi.com/phone?action=recharge&%s";
$username ='testname';
$apikey ='testapikey';
$mobile ='18801850000';
$package =1;
$orderId ='TEST_'.date("YmdHis").mt_rand(100, 1000);
$dataGet = array();
$dataGet['package'] =$package;
$dataGet['username'] =$username;
$dataGet['timestamp'] =date("YmdHis");
$dataGet['mobile'] =$mobile;
$dataGet['orderid'] =$orderId;
$dataGet['sign'] =md5(sprintf(“apikey=%s&mobile=%s&orderid=%s&package=%s×tamp=%s&username=%s”,
$apikey,
$mobile,
$orderid,
$package,
date("YmdHis"),
$username));
$dataReturn = array();
foreach ($dataGet as $key => $row) {
$dataReturn[] = sprintf("%s=%s", $key, $row);
}
$urlGet = sprintf($basicUrl,implode("&", $dataReturn));
$ch = \curl_init();
curl_setopt($ch, CURLOPT_URL, $urlGet);//定义表单提交地址
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);//60秒
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_REFERER,'http://' . $_SERVER['HTTP_HOST']);
curl_setopt($ch, CURLOPT_POST, 0);
$data = curl_exec($ch);
curl_close($ch);
$res = explode("\r\n\r\n", $data);
$dataRet = $res[1];
if ($dataRet['code'] == 1) {
//提交成功
$apiTaskid = $dataRet['taskid'];
} else {
//提交错误处理
//.....
}