Heim  >  Artikel  >  Backend-Entwicklung  >  微信通用接口文档_PHP教程

微信通用接口文档_PHP教程

WBOY
WBOYOriginal
2016-07-20 10:59:071311Durchsuche

简介

通用接口是使用HTTP请求,让开发者直接与微信服务器交互,实现媒体文件上传、媒体文件获取等功能,达到获取图片、语音、视频等媒体文件的目的。

调用接口所需要的access_token必须通过获取凭证接口获取。

获取凭证

接口说明

在使用通用接口前,你需要做以下两步工作:

1.拥有一个微信公众账号,并获取到appid和appsecret(在公众平台申请自定义菜单功能,开启开发者模式,填写URL与Token后获得)

2.通过获取凭证接口获取到access_token

注意:

access_token是第三方访问api资源的票据;
access_token对应于公众号是全局唯一的票据,重复获取将导致上次获取的access_token失效。

请求说明

http请求方式: GET
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET

参数说明

参数 是否必须 说明
grant_type 获取access_token填写client_credential
appid 第三方用户唯一凭证
secret 第三方用户唯一凭证密钥,既appsecret

返回说明

正确的Json返回结果:

{"access_token":"ACCESS_TOKEN","expires_in":7200}
参数 说明
access_token 获取到的凭证
expires_in 凭证有效时间,单位:秒

错误的Json返回示例:

{"errcode":40013,"errmsg":"invalid appid"}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445641.htmlTechArticle简介 通用接口是使用HTTP请求,让开发者直接与微信服务器交互,实现媒体文件上传、媒体文件获取等功能,达到获取图片、语音、视频等...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn