手机话费充值API事例_话费接口DEMO

接口服务商:互亿无线(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&timestamp=%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 {

     //提交错误处理

     //.....

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值