首页 加油卡充值 加油卡充值示例代码 加油卡充值[PHP]

加油卡充值示例代码[PHP]

作者: 阅读数:1991 上传时间:2016-03-10

加油卡充值

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$fuelcard = '1000110000001234567';//要充值的加油卡卡号
$amount = 200;//充值的金额 单位:元
$outorderno = '';//外部订单号
$appsecret = 'ssssssssssss';
$queryarr = array('fuelcard'=>$fuelcard,'amount'=>$amount,'outorderno'=>$outorderno);
$sign = makeSign($queryarr, $appsecret);//md5(fuelcard,amount,outorderno按key排序)
$url = "https://api.jisuapi.com/fuelcardrecharge/recharge?appkey=$appkey&fuelcard=$fuelcard&amount=$amount&outorderno=$outorderno&sign=$sign";

$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

$result = $jsonarr['result'];
echo $result['fuelcard'].' '.$result['amount'].' '.$result['totalfee'].' '.$result['outorderno'].' '.$result['orderno'].' '.$result['rechargestatus'];


function makeSign($queryarr, $appsecret)
{
    ksort($queryarr, SORT_STRING);
    $str = implode($queryarr);
    $str .= $appsecret;
    //exit($str);
    $str = md5($str);
    
    return $str;
}