/**
  * 执行支付API调用,返回结果数组
  *
  * @param array $params 调用支付API时带的参数 参考http://wiki.open.qq.com/wiki/v3/pay/buy_goods
  * @return array 结果数组
  */
 public function buyGoods($params)
 {
     $cee_extend = getenv("CEE_DOMAINNAME") . '*' . getenv("CEE_VERSIONID") . '*' . getenv("CEE_WSNAME");
     $params["cee_extend"] = $cee_extend;
     $ret = parent::api('/v3/pay/buy_goods', $params, 'post', 'https');
     return $ret;
 }
// $appid = 1101493548;
// $appkey = 'W82mDFvqubquxi9P';
$openid = '01B30933D45BC52A869A1C5AD2E2FBED';
$openkey = '38AB0FB09FE3476ECF7D88586A012F65';
// 应用基本信息
//$appid = 100657839;
//$appkey = 'b96b85196a04ff2ef08707f43979db15';
// OpenAPI的服务器IP
// 最新的API服务器地址请参考wiki文档: http://wiki.open.qq.com/wiki/API3.0%E6%96%87%E6%A1%A3
$server_name = '119.147.19.43';
// 用户的OpenID/OpenKey
//$openid = 'E098C1E975A2459E534B48FB3224CFB6';
//$openkey = '05219DB6D7C04CA0B3F01A51D32635E3';
// 所要访问的平台, pf的其他取值参考wiki文档: http://wiki.open.qq.com/wiki/API3.0%E6%96%87%E6%A1%A3
$pf = 'qzone';
$sdk = new OpenApiV3($appid, $appkey);
$sdk->setServerName($server_name);
$ret = get_user_info($sdk, $openid, $openkey, $pf);
print_r("===========================\n");
print_r($ret);
/**
 * 获取好友资料
 *
 * @param object $sdk OpenApiV3 Object
 * @param string $openid openid
 * @param string $openkey openkey
 * @param string $pf 平台
 * @return array 好友资料数组
 */
function get_user_info($sdk, $openid, $openkey, $pf)
{
 * @History:
 *               3.0.4 | coolinchen | 2012-09-07 10:20:12 | initialization
 */
require_once 'OpenApiV3.php';
// 应用基本信息
$appid = 100657839;
$appkey = 'b96b85196a04ff2ef08707f43979db15';
// OpenAPI的服务器IP
// 最新的API服务器地址请参考wiki文档: http://wiki.open.qq.com/wiki/API3.0%E6%96%87%E6%A1%A3
$server_name = '119.147.19.43';
// 用户的OpenID/OpenKey
$openid = 'E098C1E975A2459E534B48FB3224CFB6';
$openkey = '05219DB6D7C04CA0B3F01A51D32635E3';
// 所要访问的平台, pf的其他取值参考wiki文档: http://wiki.open.qq.com/wiki/API3.0%E6%96%87%E6%A1%A3
$pf = 'tapp';
$sdk = new OpenApiV3($appid, $appkey);
$sdk->setServerName($server_name);
$ret = add_weibo_pic($sdk, $openid, $openkey, $pf);
print_r("===========================\n");
print_r($ret);
/**
 * 发表带图片的微博
 *
 * @param object $sdk OpenApiV3 Object
 * @param string $openid openid
 * @param string $openkey openkey
 * @param string $pf 平台
 * @return array 微博接口调用结果
 */
function add_weibo_pic($sdk, $openid, $openkey, $pf)
{
Exemple #4
0
<?php

require_once __DIR__ . '/lib/OpenApiV3.php';
require_once 'config.php';
require dirname(__FILE__) . "/../utils/util.php";
//http://wiki.open.qq.com/wiki/v3/pay/buy_goods
// v3/pay/buy_goods
// HTTP GET /mpay/buy_goods_m?openid=67E87013295359D1E1C300EE6BC1230F&openkey=7022343841EB434C713E16A008799AC8&pay_token=E1EB7DD2CC7459DD058B83642CECC2C8&appid=1450005915&ts=1453445462&sig=ar66I%2BxFBJ6MMi1gEr9y%2BOvm%2BVg%3D&pf=desktop_m_qq-73213123-android-73213123-qq-1105115982-67E87013295359D1E1C300EE6BC1230F&pfkey=pfkey&zoneid=1&payitem=1*1*1&goodsmeta=1*1&goodsurl=1app_metadata=10000#23
$sdk = new OpenApiV3($appid, $appkey);
$sdk->setServerName($server_name);
$params = array();
$cookie = array();
// 得到请求方式
$method = $_SERVER['REQUEST_METHOD'];
if ($method == "GET") {
    $params = $_GET;
} elseif ($method == "POST") {
    $params = $_POST;
} else {
    error_log(FormatLogStr('midas', 'createorder', ERROR_PARAM, 'invalidate request method : ' . $method));
    return;
}
if (isset($params['pay_token'])) {
    $params = array('pfkey' => 'pfkey', 'pay_token' => $params['pay_token'], 'payitem' => $params['payitem'], 'pf' => $params['pf'], 'openid' => $params['openid'], 'openkey' => $params['openkey'], 'ts' => time(), 'goodsmeta' => $params['goodsmeta'], 'goodsurl' => $params['goodsurl'], 'zoneid' => 1, 'app_metadata' => $params['app_metadata']);
    $cookie = array('session_id' => 'openid', 'session_type' => 'kp_actoken', 'org_loc' => urlencode('/mpay/buy_goods_m'));
} else {
    $params = array('pfkey' => 'pfkey', 'pay_token' => '', 'payitem' => $params['payitem'], 'pf' => $params['pf'], 'openid' => $params['openid'], 'openkey' => $params['openkey'], 'ts' => time(), 'goodsmeta' => $params['goodsmeta'], 'goodsurl' => $params['goodsurl'], 'zoneid' => 1, 'app_metadata' => $params['app_metadata']);
    $cookie = array('session_id' => 'hy_gameid', 'session_type' => 'wc_actoken', 'org_loc' => urlencode('/mpay/buy_goods_m'));
}
$params['appmode'] = 1;
$ret = $sdk->api('/mpay/buy_goods_m', $params, $cookie, 'get', 'http');
Exemple #5
0
header("Content-type: text/html; charset=utf-8");
log::init('./log', 'qq_log');
$uri = $_SERVER['REQUEST_URI'];
$method = strtoupper($_SERVER['REQUEST_METHOD']);
if ("GET" == $method) {
    $params = $_GET;
} else {
    if ("POST" == $method) {
        $body = file_get_contents('php://input');
        $params = $_POST;
    }
}
log::instance()->debug("new con: {$uri} {$body}");
$appid = '1102506911';
$pf_info = $config["tencent"][$appid];
$openApi = new OpenApiV3($appid, $pf_info['AppKey']);
$openApi->setServerName('openapi.tencentyun.com');
// 查询余额
$pay_params = array('openid' => $params['openid'], 'openkey' => $params['openkey'], 'pay_token' => $params['pay_token'], 'ts' => time(), 'pf' => $params['pf'], 'zoneid' => $params['zoneid'], 'pfkey' => $params['pfkey']);
$pay_cookie = array('session_id' => 'openid', 'session_type' => 'kp_actoken', 'org_loc' => '/mpay/get_balance_m');
$result = $openApi->api($pay_cookie['org_loc'], $pay_params, $pay_cookie, 'GET', 'https');
$result['msg'] = urlencode($result['msg']);
$response = array('type' => 1, 'ret' => $result['ret']);
if ($result['ret'] !== 0) {
    log::instance()->error("ret: 查询失败 " . urldecode(json_encode($result)));
    echo json_encode($response);
    exit;
} else {
    if ($result['balance'] - $result['gen_balance'] < $params['save_num']) {
        log::instance()->error("ret: 余额不足 " . urldecode(json_encode($result)));
        $response['msg'] = "余额不足";
Exemple #6
0
/**
 * 申请购买物品
 * @param $openid
 * @param $openkey
 * @param $pf
 * @param $pfkey
 * @param $item
 * @param $itemnum
 */
function method_Paytoken($openid, $openkey, $pf, $pfkey, $item, $itemnum, $host)
{
    $item_String = common::getItemInfo($item);
    if ($item_String == NULL) {
        return json_encode(array("ret" => 1, "msg" => '出售的物品不存在!'));
    }
    $server_index = $GLOBALS['ZONE_ID'];
    if ($server_index == -1) {
        return json_encode(array("ret" => 1, "msg" => '购买异常请联系游戏客服!'));
    }
    $item_JSON = json_decode($item_String, true);
    if (isset($item_JSON['id']) && isset($item_JSON['price'])) {
        $itemID = $item_JSON['id'];
        $itemname = $item_JSON['name'];
        $itemprice = $item_JSON['price'];
        $itemDesc = $item_JSON['name'];
        $itemURL = "http://app100722626.imgcache.qzoneapp.com/app100722626/1000/store/" . $item_JSON['url'] . ".jpg";
        $appkey = $GLOBALS['APPKEY'];
        $appid = $GLOBALS['APPID'];
        $ts = time();
        $payitem = $itemID . '*' . $itemprice . '*' . $itemnum;
        $goodsmeta = $itemname . '*' . $itemDesc;
        $goodsurl = $itemURL;
        $zoneid = $server_index;
        $appmode = "2";
        //1表示用户不可以修改物品数量,2表示用户可以选择购买物品的数量。 默认为2;
        $sdk = new OpenApiV3($appid, $appkey);
        $sdk->setServerName($GLOBALS['SERVER_NAME']);
        $param = array('appid' => $appid, 'appmode' => $appmode, 'goodsmeta' => $goodsmeta, 'goodsurl' => $goodsurl, 'openid' => $openid, 'openkey' => $openkey, 'payitem' => $payitem, 'pf' => $pf, 'pfkey' => $pfkey, 'ts' => $ts, 'zoneid' => $zoneid);
        $response = $sdk->api('/v3/pay/buy_goods', $param, 'post', 'https');
        if (isset($response['ret'])) {
            $key_token = "";
            if ($response['ret'] == 0) {
                return json_encode(array("ret" => $response['ret'], "url_params" => $response['url_params'], "token" => $response['token']));
            } else {
                $errormsg = "返回异常";
                if (isset($response['msg'])) {
                    $errormsg = $response['msg'];
                }
                return json_encode(array("ret" => $response['ret'], "msg" => $errormsg));
            }
        } else {
            return json_encode(array("ret" => 1, "msg" => '请求异常,请联系客服人员!'));
        }
    } else {
        return json_encode(array("ret" => 1, "msg" => '出售的物品不存在!'));
    }
}
 /**
  * qq授权
  */
 protected function qqOauth($accessToken, $qqUid)
 {
     require_once __DIR__ . '/oauth/QQAPI/OpenApiV3.php';
     $oauth = new OpenApiV3($this->sdkconfig['QQ']['QQAppID'], $this->sdkconfig['QQ']['QQAppKey']);
     $oauth->setServerName($this->sdkconfig['QQ']['QQServerUrl']);
     $content = $oauth->api('/user/get_user_info', array('access_token' => $accessToken, 'oauth_comsumer_key' => $this->sdkconfig['QQ']['QQAppID'], 'openid' => $qqUid, 'format' => 'json'), 'get', 'https');
     return $content;
 }