• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_access_token函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_access_token函数的典型用法代码示例。如果您正苦于以下问题:PHP get_access_token函数的具体用法?PHP get_access_token怎么用?PHP get_access_token使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_access_token函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_base_information

function get_base_information($openid)
{
    $accessToken = get_access_token();
    $url = sprintf('https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN', $accessToken, $openid);
    $res = http_get_data($url);
    return $res;
}
开发者ID:yunzhiclub,项目名称:wemall,代码行数:7,代码来源:function.php


示例2: InitConfig

 /**
  * 组装配置信息
  * @param $url
  * return json
  */
 public function InitConfig($url)
 {
     $info = get_token_appinfo();
     //appId $appid = 'wxaa3ddf43e19630ee';    //$secret = '2946a5c98f49087208212f9bcba69379';
     $appid = $info['appid'];
     $secret = $info['secret'];
     //生成签名的时间戳  //生成签名的随机串
     $nonceStr = $timestamp = 12345678901;
     $access_token = get_access_token();
     if (empty($access_token)) {
         $auth = file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret);
         $token = json_decode($auth);
         $t = get_object_vars($token);
         //转换成数组
         $access_token = $t['access_token'];
         //输出access_token
     }
     $jsapi_contents = file_get_contents("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" . $access_token . "&type=jsapi");
     $jsapi = json_decode($jsapi_contents);
     $j = get_object_vars($jsapi);
     $jsapi_ticket = $j['ticket'];
     //get JSAPI
     $and = "jsapi_ticket=" . $jsapi_ticket . "&noncestr=" . $nonceStr . "&timestamp=" . $timestamp . "&url=" . $url . "";
     $signature = sha1($and);
     $arr['appId'] = $appid;
     $arr['timestamp'] = $timestamp;
     $arr['nonceStr'] = $nonceStr;
     $arr['signature'] = $signature;
     echo json_encode($arr);
     //输出json数据
 }
开发者ID:Backflag,项目名称:weiphp2.0.1202,代码行数:36,代码来源:WXShareController.class.php


示例3: get_video_upload_info

function get_video_upload_info()
{
    //get youtube access token
    $access_token = get_access_token();
    $sql = "SELECT p.profilePlaceId, p.nicename, l.businessName, l.subscribe,u.state,v.link,cam.brand, cam.tag1, cam.tag2 FROM businessProfile AS p\n\t\tLEFT JOIN businessList AS l ON l.id = p.profilePlaceId\n\t\tLEFT JOIN businessUserGroup AS u ON u.gId = l.userGroupId\n\t\tLEFT JOIN businessvanitylink AS v ON v.placeId = l.id\n\t\tLEFT JOIN campaigndetails AS cam ON cam.posterId = l.id\n\t\tLEFT JOIN businessCustom AS c ON c.customPlaceId = p.profilePlaceId\n\t\tWHERE p.profilePlaceId =  {$_SESSION['placeIdVid']}\n\t\tLIMIT 1";
    $result1 = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_object($result1);
    $title = $_REQUEST['videotitle'];
    if ($title == '') {
        $title = $row->businessName . ' Video';
    }
    //create a video obj with temp info
    $video_title = $title;
    $video_desc = $row->businessName . ' -- ' . strtolower($row->tag1) . ' ' . strtolower($row->tag2) . ' by ' . $row->brand . ' ' . 'http://camrally.com/' . $row->nicename . '.html';
    $video_keywords = $row->businessName . ', ' . 'Camrally, Campaign';
    //setup request body as xml
    $xml_str = implode('', array('<?xml version="1.0"?>', '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007">', '<media:group>', '<media:title type="plain">' . $video_title . '</media:title>', '<media:description type="plain">' . $video_desc . '</media:description>', '<media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Animals</media:category>', '<media:keywords>' . $video_keywords . '</media:keywords>', '<yt:accessControl action="list" permission="denied"/>', '</media:group>', '</entry>'));
    //use curl to call youtube api
    $ch = curl_init('http://gdata.youtube.com/action/GetUploadToken');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $access_token, 'GData-Version: 2', 'X-GData-Key: key=AI39si4ZlJR_8DWIfv_VchkxZn4R3NJ0NzVli9zFkoc35FCP83ps_exV2Qe8v5zSkbxRDw3_TPbuOpWeuN_bhaAl3UzOfk-CJA', 'Content-Type: application/atom+xml; charset=UTF-8'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_str);
    //send request
    $xml_response = curl_exec($ch);
    //close connection
    curl_close($ch);
    $result = simplexml_load_string($xml_response);
    if ($result->getName() === 'errors') {
        return array('post_url' => 'broke', 'upload_token' => 'not_a_real_token');
    }
    return array('post_url' => (string) $result->url, 'upload_token' => (string) $result->token);
}
开发者ID:Tripbull,项目名称:newrepo,代码行数:35,代码来源:youtubeapi.php


示例4: _thumb_media_id

 function _thumb_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if ($res) {
             return '';
         }
     }
     $path = $cover['path'];
     if (!$path) {
         return '';
     }
     $param['type'] = 'thumb';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return '';
     }
     $map['cover_id'] = $cover_id;
     $map['manager_id'] = $this->mid;
     $this->where($map)->setField('thumb_media_id', $res['media_id']);
     return $res['media_id'];
 }
开发者ID:walkingmanc,项目名称:weshop,代码行数:30,代码来源:MaterialModel.class.php


示例5: checkUser

 function checkUser()
 {
     /**
      * QQ互联登录,授权成功后会回调此地址
      * 必须要用授权的request token换取access token
      * 访问QQ互联的任何资源都需要access token
      * 目前access token是长期有效的,除非用户解除与第三方绑定
      * 如果第三方发现access token失效,请引导用户重新登录QQ互联,授权,获取access token
      */
     //授权成功后,会返回用户的openid
     //检查返回的openid是否是合法id
     if (!is_valid_openid($_REQUEST["openid"], $_REQUEST["timestamp"], $_REQUEST["oauth_signature"], $this->skey)) {
         return false;
     }
     //tips
     //这里已经获取到了openid,可以处理第三方账户与openid的绑定逻辑
     //但是我们建议第三方等到获取accesstoken之后在做绑定逻辑
     //用授权的request token换取access token
     $access_str = get_access_token($this->akey, $this->skey, $_REQUEST["oauth_token"], $_REQUEST['oauth_token_secret'], $_REQUEST["oauth_vericode"]);
     //echo "access_str:$access_str\n";
     $result = array();
     parse_str($access_str, $result);
     //error
     if (isset($result["error_code"])) {
         return false;
     }
     //获取access token成功后也会返回用户的openid
     //我们强烈建议第三方使用此openid
     //检查返回的openid是否是合法id
开发者ID:openbizx,项目名称:openbizx-cubix,代码行数:29,代码来源:qzone.class.php


示例6: replyCode

 public function replyCode()
 {
     $openId = (string) $this->postObj->FromUserName;
     $customerInfo = get_customer_info($openId);
     $customerId = $customerInfo['id'];
     $url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s';
     $accessToken = get_access_token();
     $url = sprintf($url, $accessToken);
     $data['expire_seconds'] = 1800;
     $data['action_name'] = $this->actionName;
     $data['action_info'] = array('scene' => array('scene_id' => (int) $customerId));
     $data = json_encode($data);
     //                $replyMessage = A('ReplyMessage');
     //            $replyMessage->setText('传入的JSON数据为' . $data);
     //            $replyMessage->replyTextMessage();
     //            return;
     $res = http_post_json($url, $data);
     $res = json_decode($res);
     $ticket = $res->ticket;
     $ticket = urlencode($ticket);
     $replyMessage = A('ReplyMessage');
     $picUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . $ticket;
     $url = $picUrl;
     $title = '您的专属二维码';
     $description = '其它用户通过扫描该二维码关注我们,将自动成为您的朋友。';
     $news[] = array('title' => $title, 'description' => $description, 'picurl' => $picUrl, 'url' => $url);
     $replyMessage->setNews($news);
     $replyMessage->replyNewsMessage();
 }
开发者ID:yunzhiclub,项目名称:wemall,代码行数:29,代码来源:ReplyQRCodeController.class.php


示例7: move_group

 function move_group($id, $group_id)
 {
     is_array($id) || ($id = explode(',', $id));
     $data['uid'] = $map['uid'] = array('in', $id);
     // $data ['group_id'] = $group_id; //TODO 前端微信用户只能有一个微信组
     $res = M('auth_group_access')->where($data)->delete();
     $data['group_id'] = $group_id;
     foreach ($id as $uid) {
         $data['uid'] = $uid;
         $res = M('auth_group_access')->add($data);
         // 更新用户缓存
         D('Common/User')->getUserInfo($uid, true);
     }
     $group = $this->find($group_id);
     // 同步到微信端
     if (C('USER_GROUP') && !empty($group['wechat_group_id'])) {
         $url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=' . get_access_token();
         $map['token'] = get_token();
         $follow = M('public_follow')->where($map)->field('openid, uid')->select();
         foreach ($follow as $v) {
             if (empty($v['openid'])) {
                 continue;
             }
             $param['openid'] = $v['openid'];
             $param['to_groupid'] = $group['wechat_group_id'];
             $param = JSON($param);
             $res = post_data($url, $param);
         }
     }
     return $group;
 }
开发者ID:yxz1025,项目名称:weiphp3.0,代码行数:31,代码来源:AuthGroupModel.class.php


示例8: getAndUploadWxImage

 public function getAndUploadWxImage($mediaId)
 {
     $access_token = get_access_token();
     //下载图片
     $url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$access_token}&media_id={$mediaId}";
     $fileInfo = $this->downloadWeixinFile($url);
     return $this->saveWeixinFile($fileInfo);
 }
开发者ID:yunzhiclub,项目名称:wemall,代码行数:8,代码来源:AttachmentModel.class.php


示例9: __CONSTRUCT

	public function __CONSTRUCT() {
		$this->token = TOKEN;
		$this->appID = APP_ID;
		$this->appSecret = APP_SECRET;
		$this->accessToken = get_access_token();
		//$this->accessToken = RUNTIME_PATH . TOKEN . '_access_token';
		//if (! file_exists ( $this->accessToken )) {
		//	$this->AccessTokenGet ();
		//}
	}
开发者ID:strivi,项目名称:siples,代码行数:10,代码来源:QRCode.php


示例10: run

 public function run()
 {
     $moreRequestMessage = getMoreRequestMessage();
     $this->fromusername = $moreRequestMessage["fromusername"];
     $this->tousername = $moreRequestMessage["tousername"];
     $this->msgtype = $moreRequestMessage["msgtype"];
     //是否开启菜单
     if (!!$this->config->item("ismenu")) {
         $access_token = get_access_token();
         createmenu($access_token);
     }
     //判断消息类型
     switch ($this->msgtype) {
         case 'event':
             //判断事件类型
             $this->event = $moreRequestMessage["event"];
             $this->handleEventMessage($this->event);
             break;
         case 'text':
             $keyMessage = getKeyRequestTextMessage();
             $content = $keyMessage['content'];
             $this->responseTextMessage($content);
             break;
         case 'image':
             $keyMessage = getKeyRequestImageMessage();
             $picurl = $keyMessage['picurl'];
             $mediaid = $keyMessage['mediaid'];
             $this->responseImageMessage($picurl, $mediaid);
             break;
         case 'location':
             $keyMessage = getKeyRequestLocationMessage();
             $location_x = $keyMessage['location_x'];
             $location_y = $keyMessage['location_y'];
             $scale = $keyMessage['scale'];
             $label = $keyMessage['label'];
             $this->responseLocationMessage($location_x, $location_y, $scale, $label);
             break;
         case 'link':
             $keyMessage = getKeyRequestLinkMessage();
             $title = $keyMessage['title'];
             $description = $keyMessage['description'];
             $url = $keyMessage['url'];
             $this->responseLinkMessage($title, $description, $url);
             break;
         case 'voice':
             $keyMessage = getKeyRequestVoiceMessage();
             $mediaid = $keyMessage['mediaid'];
             $format = $keyMessage['format'];
             $this->responseVoiceMessage($mediaid, $format);
             break;
         default:
             $this->responseUnknownMessage();
             break;
     }
 }
开发者ID:lnmpoo,项目名称:wechat_ci,代码行数:55,代码来源:SAE_Controller.php


示例11: get_acc_tokens

function get_acc_tokens($request_token, $request_token_secret)
{
    $retarr = get_access_token(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $request_token, $request_token_secret, false, true, true);
    if (!empty($retarr)) {
        list($info, $headers, $body, $body_parsed) = $retarr;
        if ($info['http_code'] == 200 && !empty($body)) {
            return $retarr[3];
        }
    } else {
        echo "Empty array" . "\n";
    }
}
开发者ID:0x27,项目名称:mrw-code,代码行数:12,代码来源:getacctok.php


示例12: getaccess_token

 function getaccess_token()
 {
     //$where = array('token' => get_token());
     //$this->thisWxUser = M('member_public')->where($where)->find();
     //$url_get = (('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $this->thisWxUser['appid']) . '&secret=') . $this->thisWxUser['secret'];
     //$json = json_decode($this->curlGet($url_get));
     //if (!$json->errmsg) {
     //} else {
     //	$this->error((('获取access_token发生错误:错误代码' . $json->errcode) . ',微信返回错误信息:') . $json->errmsg);
     //}
     //return $json->access_token;
     return get_access_token();
 }
开发者ID:strivi,项目名称:siples,代码行数:13,代码来源:BaseController.class.php


示例13: sendtempmsg

 public function sendtempmsg($openid, $template_id, $url, $data, $topcolor = '#FF0000')
 {
     $xml = '{"touser":"' . $openid . '","template_id":"' . $template_id . '","url":"' . $url . '","topcolor":"' . $topcolor . '","data":' . $data . '}';
     $res = $this->curlPost('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . get_access_token(), $xml);
     $res = json_decode($res, true);
     // 记录日志
     if ($res['errcode'] == 0) {
         addWeixinLog($xml, 'post');
     }
     $senddata = array('openid' => $openid, 'template_id' => $template_id, 'MsgID' => $res['msgid'], 'message' => $data, 'sendstatus' => $res['errcode'] == 0 ? 0 : 1, 'token' => get_token(), 'ctime' => time());
     M('tmplmsg')->add($senddata);
     return $res;
 }
开发者ID:strivi,项目名称:siples,代码行数:13,代码来源:TmplmsgController.class.php


示例14: test

 function test()
 {
     $param['touser'] = "o3ZYauOnS_g-qQ9bYISisG2MLfvE";
     $param['msgtype'] = "text";
     $param['text']['content'] = "Hello World!";
     $param['customservice']['kf_account'] = "zbyy@nyfslg";
     $param_json = json_encode($param);
     dump($param_json);
     $token = get_token();
     $access_token = get_access_token($token);
     $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $access_token;
     $return = http_post($url, $param_json);
     dump($return);
 }
开发者ID:strivi,项目名称:siples,代码行数:14,代码来源:SendredpackController.class.php


示例15: db_get_token_ticket

/**
 * 依赖于数据库2小时缓存获取token,ticket
 * @param $appid
 * @param $secret
 * @return array    包含token,ticket的数组
 */
function db_get_token_ticket($appid, $secret)
{
    $token = "                                                                                                                                                                                                                                                                ";
    $ticket = "                                                                                                                                                                                                                                                                ";
    $params = array(array($appid, SQLSRV_PARAM_IN), array($token, SQLSRV_PARAM_OUT), array($ticket, SQLSRV_PARAM_OUT));
    sp_execute("{call weixin_get_token(?,?,?)}", $params);
    if (strlen($token) == 0 || strlen($ticket) == 0) {
        $token = get_access_token($appid, $secret);
        $ticket = get_jsapi_ticket($token);
        $params = array(array($appid, SQLSRV_PARAM_IN), array($token, SQLSRV_PARAM_IN), array($ticket, SQLSRV_PARAM_IN));
        sp_execute("{call weixin_set_token(?,?,?)}", $params);
    }
    return array("token" => $token, "ticket" => $ticket);
}
开发者ID:noikiy,项目名称:Bentley,代码行数:20,代码来源:db_weixin_funs.php


示例16: indexAction

 public function indexAction()
 {
     //取出openId数据组
     $accessToken = get_access_token();
     $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . $accessToken;
     $jsonData = http_get_data($url);
     $data = json_decode($jsonData);
     $openids = $data->data->openid;
     //取出openid对应的其它信息
     $userInfo = array();
     foreach ($openids as $key => $value) {
         $userInfo[] = get_weichat_user_info($value, $accessToken);
     }
     $customer = D('Customer');
     $customer->addUserInfo($userInfo);
     $this->success('列表获取完成', U('Index/index'), 2);
 }
开发者ID:yunzhiclub,项目名称:wemall,代码行数:17,代码来源:ListCustomerController.class.php


示例17: update_wxmenu

 public function update_wxmenu()
 {
     $hset = $this->check_wechat();
     $data = [];
     for ($i = 1; $i <= 3; $i++) {
         $data[$i] = json_decode($this->ad_cache->get_wx_menu($hset, $i), true);
     }
     $menu = generate_menu_from_redis($data);
     $access_token = get_access_token(APPID, APPSECRET);
     $info = json_decode(post_tab($access_token, json_encode($menu, JSON_UNESCAPED_UNICODE)), true);
     if ($info["errcode"] == "0") {
         $res = "更新自定义菜单成功";
     } else {
         $res = "更新自定义菜单失败\n错误代码:" . $info["errcode"] . "\n错误信息:" . $info["errmsg"];
     }
     echo $res;
 }
开发者ID:qinzhe,项目名称:wxmenu,代码行数:17,代码来源:wxmenu_manage.php


示例18: getJsApiTicket_temp

 private function getJsApiTicket_temp($token = '')
 {
     empty($token) && ($token = get_token());
     $key = 'jsapi_ticket_' . $token;
     $res = S($key);
     if ($res !== false) {
         return $res;
     }
     $access_token = get_access_token();
     $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=' . $access_token . '&type=jsapi';
     $tempArr = json_decode(file_get_contents($url), true);
     if (@array_key_exists('ticket', $tempArr)) {
         S($key, $tempArr['ticket'], 7200);
         return $tempArr['ticket'];
     } else {
         return 0;
     }
 }
开发者ID:strivi,项目名称:siples,代码行数:18,代码来源:JssdkApi.class.php


示例19: send_ewm

 function send_ewm()
 {
     //-----获取access_token
     $access_token = get_access_token();
     //----生成二维码
     $ewmid = I('ewmid');
     $postUrl = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $access_token;
     $postJson = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": ' . $ewmid . '}}}';
     $return = json_decode(http_post($postUrl, $postJson), true);
     if ($return['errcode'] == 0) {
         $ticket = $return['ticket'];
         $qr_code = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . UrlEncode($ticket);
         $this->qr_code_save($qr_code, $ewmid);
         $this->success('生成二维码成功');
     } else {
         $this->error('生成二维码失败,错误的返回码是:' . $res['errcode'] . ', 错误的提示是:' . $res['errmsg']);
     }
 }
开发者ID:strivi,项目名称:siples,代码行数:18,代码来源:QrcodeController.class.php


示例20: get_access_token

function get_access_token($appid, $secret, $retry = 0)
{
    $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
    $json = file_get_contents($url);
    $rs = json_decode($json, TRUE);
    if (!empty($rs) && empty($rs['errcode'])) {
        return $rs;
    }
    if ($rs['errcode'] == -1) {
        if ($retry < 5) {
            sleep(10);
            return get_access_token($appid, $secret, $retry + 1);
        }
        //outlog("ERROR: Refresh access token failed with retry $retry times. $rs[errcode]($rs[errmsg])");
    } else {
        //outlog("ERROR: $rs[errmsg]. (CODE=$rs[errcode])");
    }
    return 0;
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:19,代码来源:refresh_wxtoken.php



注:本文中的get_access_token函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_accesshide函数代码示例发布时间:2022-05-15
下一篇:
PHP get_access_sql_suffix函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap