Table of Contents
(一)微信公众号开发基本配置,信公众开发基本配置
Home php教程 php手册 (一)微信公众号开发基本配置,信公众开发基本配置

(一)微信公众号开发基本配置,信公众开发基本配置

Jun 16, 2016 am 09:16 AM
one code basic configuration develop Developer WeChat use want conduct

(一)微信公众号开发基本配置,信公众开发基本配置

 

作为用代码进行微信开发者或要实现事件响应等功能,微信开发基本配置是必不可少的环节,本文大致梳理开发配置的流程。

 

1、登入微信公众平台:开发 ---> 基本配置

 

 

2、在基本配置页面有“服务器配置”,默认是未启用状态,需要我们先点击“修改配置”进行相关项目填写

 

3、填写以下项目内容

 

  •  URL:必须以http://开头,目前仅支持80端口,服务器地址必须是可访问的有效地址(注:用本文中URL举例,曾经看到一篇博文将URL地址填为http://tx.heivr.com/token,但亲测实际开发中无法响应事件,修改URL至具体的文件即可成功);
  • EncodingAESKey随机生成即可;
  • token:微信特别强调了填写的URL需要响应token,因此在index.php中需要进行验证,代码如下:
    <span> 1</span> <?<span>php
    </span><span> 2</span> <span>define</span>("TOKEN", "此处填写你设置的token值"<span>);
    </span><span> 3</span> 
    <span> 4</span> <span>$wechatObj</span> = <span>new</span><span> CallbackAPI;
    </span><span> 5</span> <span>$wechatObj</span>-><span>valid();
    </span><span> 6</span> 
    <span> 7</span> <span>class</span><span> CallbackAPI {
    </span><span> 8</span> 
    <span> 9</span>     <span>/*</span><span>*
    </span><span>10</span> <span>     * 签名验证
    </span><span>11</span> <span>     * @return [type] [description]
    </span><span>12</span>      <span>*/</span>
    <span>13</span>      <span>public</span> <span>function</span><span> valid() {
    </span><span>14</span>         <span>$echoStr</span> = <span>$_GET</span>["echostr"<span>];
    </span><span>15</span>         <span>$signature</span> = <span>$_GET</span>["signature"<span>];
    </span><span>16</span>         <span>$timestamp</span> = <span>$_GET</span>["timestamp"<span>];
    </span><span>17</span>         <span>$nonce</span> = <span>$_GET</span>["nonce"<span>];
    </span><span>18</span>         <span>$token</span> =<span> TOKEN;
    </span><span>19</span>         <span>//</span><span>将token、timestamp、nonce按字典序排序</span>
    <span>20</span>         <span>$tmpArr</span> = <span>array</span>(<span>$token</span>, <span>$timestamp</span>, <span>$nonce</span><span>);
    </span><span>21</span>         <span>sort</span>(<span>$tmpArr</span><span>);      
    </span><span>22</span>         <span>$tmpStr</span> = <span>implode</span>(<span>$tmpArr</span><span>);
    </span><span>23</span>         <span>//</span><span>对tmpStr进行sha1加密</span>
    <span>24</span>         <span>$tmpStr</span> = <span>sha1</span>(<span>$tmpStr</span><span>);
    </span><span>25</span>         <span>if</span>(<span>$tmpStr</span> == <span>$signature</span><span>){
    </span><span>26</span>             <span>header</span>('content-type:text'<span>);
    </span><span>27</span>             <span>echo</span> <span>$echoStr</span><span>;
    </span><span>28</span>             <span>exit</span><span>;
    </span><span>29</span> <span>        }
    </span><span>30</span> <span>    }
    </span><span>31</span> }
    Copy after login

    在浏览器中运行index.php若程序无误即可看到返回的字符串,且此时完成验证,并将代码中的token填写到基本配置中的相应位置,点击提交。(注:提交后可能会出现“token验证失败”的提示,若检查代码及各项参数无误,则需多点击几次提交即可成功

 4、提交成功后,点击“开启”按钮,即进入开发者模式,该模式开启后功能 ---> 自定义菜单等部分功能即不可用,若想使用点击“停用”即可

 

 

 

 特此声明:相关文章均为查阅资料、阅读大神博文后结合实际开发情况遇到的问题整理而成,能找到原博的必会署名,找不到原博而引用的内容还望原博主海涵

 

 

 

 

 

 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Ouyi Exchange app domestic download tutorial Ouyi Exchange app domestic download tutorial Mar 21, 2025 pm 05:42 PM

This article provides a detailed guide to safe download of Ouyi OKX App in China. Due to restrictions on domestic app stores, users are advised to download the App through the official website of Ouyi OKX, or use the QR code provided by the official website to scan and download. During the download process, be sure to verify the official website address, check the application permissions, perform a security scan after installation, and enable two-factor verification. During use, please abide by local laws and regulations, use a safe network environment, protect account security, be vigilant against fraud, and invest rationally. This article is for reference only and does not constitute investment advice. Digital asset transactions are at your own risk.

The difference between H5 and mini-programs and APPs The difference between H5 and mini-programs and APPs Apr 06, 2025 am 10:42 AM

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

What is the difference between H5 page production and WeChat applets What is the difference between H5 page production and WeChat applets Apr 05, 2025 pm 11:51 PM

H5 is more flexible and customizable, but requires skilled technology; mini programs are quick to get started and easy to maintain, but are limited by the WeChat framework.

What should I do if the company's security software conflicts with applications? How to troubleshoot HUES security software causes common software to fail to open? What should I do if the company's security software conflicts with applications? How to troubleshoot HUES security software causes common software to fail to open? Apr 01, 2025 pm 10:48 PM

Compatibility issues and troubleshooting methods for company security software and application. Many companies will install security software in order to ensure intranet security. However, security software sometimes...

How to solve the problem of JS resource caching in enterprise WeChat? How to solve the problem of JS resource caching in enterprise WeChat? Apr 04, 2025 pm 05:06 PM

Discussion on the JS resource caching issue of Enterprise WeChat. When upgrading project functions, some users often encounter situations where they fail to successfully upgrade, especially in the enterprise...

How to choose H5 and applets How to choose H5 and applets Apr 06, 2025 am 10:51 AM

The choice of H5 and applet depends on the requirements. For applications with cross-platform, rapid development and high scalability, choose H5; for applications with native experience, rich functions and platform dependencies, choose applets.

Detailed tutorial on how to buy and sell Binance virtual currency Detailed tutorial on how to buy and sell Binance virtual currency Mar 18, 2025 pm 01:36 PM

This article provides a brief guide to buying and selling of Binance virtual currency updated in 2025, and explains in detail the operation steps of virtual currency transactions on the Binance platform. The guide covers fiat currency purchase USDT, currency transaction purchase of other currencies (such as BTC), and selling operations, including market trading and limit trading. In addition, the guide also specifically reminds key risks such as payment security and network selection for fiat currency transactions, helping users to conduct Binance transactions safely and efficiently. Through this article, you can quickly master the skills of buying and selling virtual currencies on the Binance platform and reduce transaction risks.

The first dual-core cultural and tourism digital hominid in the country! Tencent Cloud helps Huaguoshan Scenic Area connect to DeepSeek, making the 'Sage Monkey King' smarter and warmer The first dual-core cultural and tourism digital hominid in the country! Tencent Cloud helps Huaguoshan Scenic Area connect to DeepSeek, making the 'Sage Monkey King' smarter and warmer Mar 12, 2025 pm 12:57 PM

Lianyungang Huaguoshan Scenic Area joins hands with Tencent Cloud to launch the first "dual-core brain" Digital Homo sapiens in the cultural and tourism industry - Monkey King! On March 1, the scenic spot officially connected the Monkey King to the DeepSeek platform, so that it has the two AI model capabilities of Tencent Hunyuan and DeepSeek, bringing tourists a smarter and more considerate service experience. Huaguoshan Scenic Area has previously launched the Monkey King of the Digital Homo sapiens based on Tencent Hunyuan model. This time, Tencent Cloud further utilizes technologies such as the big model knowledge engine to connect it to DeepSeek to achieve a "dual-core" upgrade. This makes the Monkey King's interactive ability to a higher level, faster response speed, stronger understanding ability, and more warmth. Monkey King has strong natural language processing capabilities and can understand various ways of asking questions from tourists.

See all articles