Mobile phone bill recharge data interface_API interface

The company's activity development was just completed last week. The product demand is that after users follow our WeChat official account, they can draw a red envelope for call charges, and the amount of red packets for call charges is between 1 yuan and 10 yuan. After screening several service providers and evaluating from the aspects of interface document integrity, cost, stability, data viewing, etc., I finally chose Huyi Wireless. I will share the relevant information for the convenience of other students for later use:


Call interface service provider: Huyi Wireless (www.ihuyi.com)
call charge interface address: http://f.ihuyi.com/phone



1. Single-number recharge call charge
request (POST or GET)
type parameter name parameter value description
parameter action recharge
parameter username username (signature)
parameter mobile phone number (signature)
parameter package package amount (signature)
parameter orderid order ID (signature)
parameter timestamp timestamp (signature)
format such as: yyyyMMddHHmmss
allows 10 minutes to be unified east 8 time
parameter sign signature

return value (JSON Format)
name type description
code int code (1 means the submission is successful)
message string message description
taskid string task id, if the submission fails, there is no






 
2. Account balance query
request (POST or GET)
type parameter name parameter value description
parameter action getbalance
parameter username user first name (signature)
Parameter timestamp timestamp (signature)
format such as: yyyyMMddHHmmss
allows 10 minutes to be unified east 8 time
parameter sign

return value (JSON format)
name type description
code int code
message string message description
balance float remaining balance






3. Recharge status query
request (POST or GET)
type parameter name parameter value description
parameter action getreports
parameter username user name (signature)
parameter count number of fetches (signature)
parameter timestamp timestamp (signature)
format such as: yyyyMMddHHmmss
allows 10 minutes to be unified east 8 time
parameter sign

return value (JSON format)
name type description
code int code (1 for successful submission)
message string message description
reports+ array report
    taskid string task id
    mobile string mobile phone number
    state int status (0 failed, 1 successful)
    message string message

note: after the status is obtained The server will delete the state





4. Recharge status push
request (posted to the configured URL)
type parameter name parameter value description
parameter taskid recharge task ID
parameter mobile phone number (signature)
parameter state status (signature) 1: success 2: failure
parameter message message (signature ) ) parameter
sign signature Note

: You can only choose one of the two methods: recharge status query and recharge



status
push . ) parameter timestamp timestamp (signature) parameter sign signature return value (JSON format) name type description code int code message string message description packages+ float package     type string type (cncm: China Mobile cncu: China Unicom cnct: China Telecom)     name string phone bill Package     number int value (for recharge request)     state int status (1 enabled, 0 disabled)     price int unit price 6. Status code value description 0 Unknown error























1 Submit successfully
1000 No such operation type (action is empty or does not exist)
1001 Username is empty
1002 Username is wrong
1003 Mobile phone number is empty
1004 Mobile phone number is empty
1005 Package cannot be empty
1006 Timestamp cannot be empty
1007 Does not exist Package
1008 Signature cannot be empty
1009 Signature error
1010 Signature expired
1011 Account is frozen
1012 Insufficient balance
1013 Access ip is different from the record ip
1014 Order ID cannot be empty
1015 Order ID already exists

2001 Unsupported mobile phone number
2002 Mobile phone number has been added to the blacklist List
2003 Unsupported regions
3001 Deduction failed
4001 Internal system failure


7. Signature description
Need to put apikey (obtained by logging in the system) into the key-value pair to be signed, sort the key-value pair according to asc, sort the parameter name, and splicing the key-value pair String (parameter name lowercase), then encrypted with 32-bit md5

Note: Please use lowercase for the username,

such as:
sign=md5(aaaa=aaaa&bbbb=bbbb&cccc=cccc&dddd=dddd) The


PHP recharge signature code is as follows:
$sign = md5(sprintf(“apikey=%s&mobile=%s&orderid=%s&package=%s×tamp=%s&username=%s”,
                            $apikey,
                            $mobile,
   $orderid,
                            $package,
                            date("YmdHis"),
                            $username));

GET方式地址如:
http://f.ihuyi.com/phone?action=recharge&username=testname&mobile=13800000000&orderid=xxxxxxxxx&package=10×tamp=1457954906&sign=e08ecdcedac8f9e07b1727e1005b8d32



8.PHP充值代码DEMO

$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'];      //Submit error handling
} else {

      //.....
}

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326432094&siteId=291194637