Home > Backend Development > PHP Tutorial > WeChat access_token acquisition development example, access_token example_PHP tutorial

WeChat access_token acquisition development example, access_token example_PHP tutorial

WBOY
Release: 2016-07-13 09:56:54
Original
969 people have browsed it

WeChat access_token acquisition development example, access_token example

Overview

Access_token is the globally unique ticket of the public account. The public account needs to use access_token when calling each interface. Developers need to store it properly. At least 512 characters of space must be reserved for access_token storage. The validity period of access_token is currently 2 hours and needs to be refreshed regularly. Repeated acquisition will cause the last access_token to become invalid.

Acquisition of access_token

<&#63;php

define("APPID", "您的appid");
define("APPSECRET", "您的appsecret ");

$token_access_url = "https://api.weixin.qq.com/cgi-bin/token&#63;grant_type=client_credential&appid=" . APPID . "&secret=" . APPSECRET;
$res = file_get_contents($token_access_url); //获取文件内容或获取网络请求的内容
//echo $res;
$result = json_decode($res, true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量
$access_token = $result['access_token'];
echo $access_token;

php>
Copy after login

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/985273.htmlTechArticleWeChat access_token acquisition development example, access_token example overview access_token is the global unique ticket of the official account, and the official account calls each interface access_token is required whenever. Developers need to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template