コード例 #1
0
ファイル: base.php プロジェクト: qujian/ydwx
function ydwx_refresh_card_jsapi_ticket($token)
{
    $http = new YDHttp();
    $msg = $http->get(YDWX_WEIXIN_BASE_URL . "ticket/getticket?type=wx_card&access_token=" . $token);
    $ticket = new YDWXJsapiTicketResponse($msg);
    if ($ticket->isSuccess()) {
        return $ticket;
    }
    throw new YDWXException($ticket->errmsg, $ticket->errcode);
}
コード例 #2
0
ファイル: card-hasmp.php プロジェクト: qujian/ydwx
/**
 * 该接口用于查询母商户资质审核的结果,审核通过后才能用接口继续提交子商户资质。
 * @param unknown $accessTokent  第三方平台的access token
 * @throws YDWXException
 * @return YDWX_CARD_CHECK_AGENT_QUALIFICATION_XX常量
 */
function ydwx_card_check_agent_qualification($accessToken)
{
    $http = new YDHttp();
    $info = $http->get(YDWX_WEIXIN_BASE_URL . "component/check_card_agent_qualification?access_token={$accessToken}");
    $msg = new YDWXResponse($info);
    if ($msg->isSuccess()) {
        return $msg->result;
    }
    throw new YDWXException($msg->errmsg, $msg->errcode);
}
コード例 #3
0
ファイル: packet.php プロジェクト: qujian/ydwx
/**
 * 设置红包活动抽奖开关
 * 
 * 开发者实时控制红包活动抽奖的开启和关闭。
 * 注意活动抽奖开关只在红包活动有效期之内才能生效,
 * 如果不能确定红包活动有效期,请尽量将红包活动有效期的范围设置大。
 * 
 * @param unknown $accessToken
 * @param unknown $lottery_id 红包抽奖id,来自addlotteryinfo返回的lottery_id
 * @param boolean $onoff 活动抽奖开关,false:关闭,true:开启
 * @throws YDWXException
 * @return boolean
 */
function ydwx_packet_setlotteryswitch($accessToken, $lottery_id, $onoff)
{
    $http = new YDHttp();
    $info = $http->get(YDWX_WEIXIN_BASE_URL2 . "shakearound/lottery/setlotteryswitch?access_token={$accessToken}&lottery_id={$lottery_id}&onoff=" . ($onoff ? "1" : "0"));
    $rst = new YDWXResponse($info);
    if (!$rst->isSuccess()) {
        throw new YDWXException($rst->errmsg, $rst->errcode);
    }
    return true;
}
コード例 #4
0
ファイル: zb.php プロジェクト: qujian/ydwx
/**
 * 接口说明 查询已经提交的开通摇一摇周边功能申请的审核状态。在申请提交后,工作人员会在三个工作日内完成审核。
 * 
 * @param unknown $accessToken
 * @throws YDWXException
 * @return YDWXZBStatus
 */
function ydwx_shakearound_register_status($accessToken)
{
    $http = new YDHttp();
    $info = $http->get(YDWX_WEIXIN_BASE_URL2 . "shakearound/account/auditstatus?access_token={$accessToken}");
    $msg = new YDWXZBStatus($info);
    if ($msg->isSuccess()) {
        return $msg;
    }
    throw new YDWXException($msg->errmsg);
}
コード例 #5
0
ファイル: user.php プロジェクト: qujian/ydwx
/**
 * 网站应用获取用户信息
 * @param unknown $accessToken 注意,这里的access token是oauth认证第二步微信返回的
 * @param unknown $openid
 * @throws YDWXException
 * @return YDWXOAuthUser
 */
function ydwx_sns_userinfo($accessToken, $openid)
{
    $http = new YDHttp();
    $user = $http->get(YDWX_WEIXIN_WEB_BASE_URL . "userinfo?access_token={$accessToken}&openid={$openid}&lang=zh_CN");
    $user = new YDWXOAuthUser($user);
    if ($user->isSuccess()) {
        return $user;
    }
    throw new YDWXException($user->errmsg);
}
コード例 #6
0
ファイル: menu.php プロジェクト: qujian/ydwx
function ydwx_get_current_selfmenu_info($accessToken)
{
    $http = new YDHttp();
    $menus = json_decode($http->get(YDWX_WEIXIN_BASE_URL . "get_current_selfmenu_info?access_token=" . $accessToken), true);
    $array = array();
    if (!@$menus['selfmenu_info']['button']) {
        return array();
    }
    foreach ($menus['selfmenu_info']['button'] as $menu) {
        $array[] = YDWXMenu::build($menu);
    }
    return $array;
}
コード例 #7
0
ファイル: webauth.php プロジェクト: qujian/ydwx
<?php

/**
 * 网站进行微信OAuth登陆
 * 该页面可通过Redirect方式进行访问,或者直接在需要的地方include_once
 */
chdir(dirname(__FILE__));
//把工作目录切换到文件所在目录
include_once dirname(__FILE__) . '/__config__.php';
// state为交互时双方都会带着的get参数,用于做一些逻辑判断,如果没指定,则默认一个
if (!$state) {
    $state = "fromydwx";
}
$redirect = YDWX_SITE_URL . 'ydwx/webauth.php';
if (!@$_GET['code'] && !@$_GET['state']) {
    ob_clean();
    header("Location: https://open.weixin.qq.com/connect/qrconnect?appid=" . YDWX_WEIXIN_WEB_APP_ID . "&redirect_uri={$redirect}&response_type=code&scope=snsapi_login&state={$state}#wechat_redirect");
    die;
}
if (!@$_GET['code'] && @$_GET['state']) {
    YDWXHook::do_hook(YDWXHook::AUTH_CANCEL);
    die;
}
$http = new YDHttp();
$info = json_decode($http->get("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . YDWX_WEIXIN_WEB_APP_ID . "&secret=" . YDWX_WEIXIN_WEB_APP_SECRET . "&code=" . $_GET['code'] . "&grant_type=authorization_code"), true);
if (!@$info['openid']) {
    YDWXHook::do_hook(YDWXHook::AUTH_FAIL, YDWXAuthFailResponse::errMsg($info['errmsg'], $info['errcode']));
    die;
}
YDWXHook::do_hook(YDWXHook::AUTH_WEB_SUCCESS, ydwx_sns_userinfo($info['access_token'], $info['openid'], $_GET['state']));
コード例 #8
0
ファイル: meida.php プロジェクト: qujian/ydwx
/**
 * 下载临时文件
 * 
 * @param unknown $accessToken
 * @param unknown $mediaid
 * @param string $isVideo
 * @return boolean|content
 */
function ydwx_media_get($accessToken, $mediaid, $isVideo = false)
{
    $http = new YDHttp();
    $content = $http->get(($isVideo ? YDWX_WEIXIN_NO_SSL_URL : YDWX_WEIXIN_BASE_URL) . "media/get?access_token={$accessToken}&media_id={$mediaid}");
    $info = json_decode($content, true);
    if (array_key_exists("errcode", $info)) {
        return false;
    }
    return $content;
}
コード例 #9
0
ファイル: card-notmp.php プロジェクト: qujian/ydwx
/**
 * 批量拉取子商户信息接口
 * 母商户 可以通过该接口批量拉取 子商户的相关信息,一次调用最多拉起100个子商户的信息,可 以通过多次拉去满足不同的查询需求
 * @param unknown $accessToken  第三方平台的access token
 * @param unknown $begin_id merchant_id
 * @param unknown $limit 数量 最大100
 * @param unknown $status YDWX_CARD_MERCHANT_XX
 * @throws YDWXException
 * @return YDWXCardSubmerchantBatchGetResponse
 */
function ydwx_card_submerchant_batchget($accessToken, $begin_id, $limit, $status)
{
    if ($limit > 100) {
        throw new YDWXException("商户批量查询数量最大100");
    }
    $http = new YDHttp();
    $info = $http->get(YDWX_WEIXIN_BASE_URL2 . "card/submerchant/batchget?access_token={$accessToken}", ydwx_json_encode(array("begin_id" => intval($begin_id), "limit" => intval($limit), "status" => $status)));
    $msg = new YDWXCardSubmerchantBatchGetResponse($info);
    if ($msg->isSuccess()) {
        return $msg;
    }
    throw new YDWXException($msg->errmsg, $msg->errcode);
}
コード例 #10
0
ファイル: baseauth.php プロジェクト: qujian/ydwx
    $isAgent = false;
    $appid = YDWX_WEIXIN_ACCOUNT_TYPE == YDWX_WEIXIN_ACCOUNT_TYPE_CROP ? YDWX_WEIXIN_CROP_ID : YDWX_WEIXIN_APP_ID;
    $secret = YDWX_WEIXIN_ACCOUNT_TYPE == YDWX_WEIXIN_ACCOUNT_TYPE_CROP ? YDWX_WEIXIN_CROP_SECRET : YDWX_WEIXIN_APP_SECRET;
    $authorize_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . urlencode($redirect) . "&response_type=code&scope=snsapi_base&state={$state}#wechat_redirect";
    $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $secret . "&code=%s&grant_type=authorization_code";
}
//第一步,引导用户到微信页面授权
if (!@$_GET['code'] && !@$_GET['state']) {
    ob_clean();
    header($authorize_url);
    die;
}
//第二步,用户授权后返回,获取授权用户信息
if ($isAgent || YDWX_WEIXIN_ACCOUNT_TYPE != YDWX_WEIXIN_ACCOUNT_TYPE_CROP) {
    $http = new YDHttp();
    $info = json_decode($http->get(sprintf($access_token_url, $_GET['code'])), true);
    if (!@$info['openid']) {
        YDWXHook::do_hook(YDWXHook::AUTH_FAIL, YDWXAuthFailResponse::errMsg($info['errmsg'], $info['errcode']));
        die;
    }
    if ($isAgent) {
        $access_token = YDWXHook::do_hook(YDWXHook::GET_HOST_ACCESS_TOKEN, $appid);
    } else {
        $access_token = YDWXHook::do_hook(YDWXHook::GET_ACCESS_TOKEN);
    }
    if ($access_token) {
        try {
            $user = ydwx_user_info($access_token, $info['openid']);
        } catch (\Exception $e) {
            $user = new YDWXSubscribeUser();
            $user->openid = $info['openid'];
コード例 #11
0
ファイル: poi.php プロジェクト: qujian/ydwx
/**
 * 取得poi类目
 * @param unknown $accessToken
 * @throws YDWXException
 * @return array
 */
function ydwx_poi_getwxcategory($accessToken)
{
    $http = new YDHttp();
    $info = $http->get(YDWX_WEIXIN_BASE_URL . "api_getwxcategory?access_token={$accessToken}");
    $msg = new YDWXResponse($info);
    if ($msg->isSuccess()) {
        return $msg->category_list;
    }
    throw new YDWXException($msg->errmsg);
}