setPay($pay_appid, $pay_appkey); // 设置YSDK调用环境 $sdk->setServerName($server_name); if ($argc != 2) { echo_help(); } $fun = $argv[1]; if($fun == 'help'){ echo_help(); } if($fun == 'qq_check_token'){ $params = array( 'appid' => $appid, 'openid' => $openid, 'openkey' => $openkey, 'userip' => $userip, 'sig' => md5($appkey.$ts), 'timestamp' => $ts, ); $ret = qq_check_token($sdk, $params); print_r("============== qq_check_token ================\n"); print_r($ret); } elseif($fun == 'wx_check_token'){ $params = array( 'appid' => $wx_appid, 'openid' => $wx_openid, 'userip' => $userip, 'sig' => md5($appkey.$ts), 'access_token' => $wx_accesstoken, 'timestamp' => $ts, ); $ret = wx_check_token($sdk, $params); print_r("============== wx_check_token ================\n"); print_r($ret); } elseif($fun == 'get_balance_m'){ $params = array( 'openid' => $openid, 'openkey' => $openkey, 'pay_token' => $pay_token, 'ts' => $ts, 'pf' => $pf, 'pfkey' => $pfkey, 'zoneid' => $zoneid, ); $accout_type='qq'; $ret = get_balance_m($sdk, $params,$accout_type); print_r("============== get_balance_m ================\n"); print_r($ret); } elseif($fun == 'pay_m'){ $amt = 10; $params = array( 'openid' => $openid, 'openkey' => $openkey, 'pay_token' => $pay_token, 'ts' => $ts, 'pf' => $pf, 'pfkey' => $pfkey, 'zoneid' => $zoneid, 'amt' => $amt, ); $accout_type='qq'; $ret = pay_m($sdk, $params, $accout_type); print_r("============== pay_m ================\n"); print_r($ret); } elseif($fun == 'present_m'){ $discountid = ''; $giftid = ''; $presenttimes = 50; $params = array( 'openid' => $openid, 'openkey' => $openkey, 'pay_token' => $pay_token, 'ts' => $ts, 'pf' => $pf, 'pfkey' => $pfkey, 'zoneid' => $zoneid, 'discountid' => $discountid, 'giftid' => $giftid, 'presenttimes' => $presenttimes ); $accout_type='qq'; $ret = present_m($sdk, $params, $accout_type); print_r("============== present_m ================\n"); print_r($ret); } else{ print_r("=============fun参数缺失或者输入参数错误==============\n"); echo_help(); } function echo_help(){ print_r("============YSDK PHP SDK测试帮助===============\n"); print_r("============php SampleTest.php qq_check_token 验证手Q的登录态==================\n"); print_r("============php SampleTest.php wx_check_token 验证微信的登录态===============\n"); print_r("============php SampleTest.php get_balance_m 获取用户游戏币余额===============\n"); print_r("============php SampleTest.php pay_m 扣除游戏币接口===============\n"); } // end of script