


WeChat public platform development (73) Sending customer service messages_PHP tutorial
WeChat public platform develops customer service interface to send customer service messages
Author: Fangbei Studio
Address: http://www.cnblogs.com/txw1958/p/weixin73-custom-send.html
When a user actively sends a message to an official account (including sending a message, clicking a custom menu clike event, subscribing event, scanning QR code event, payment success event, user rights protection), WeChat will The message data will be pushed to developers. Developers can call the customer service message interface within a period of time (currently 24 hours) and send messages to ordinary users by POSTing a JSON data packet. There is no limit on the number of sending times within 24 hours. This interface is mainly used for functions such as customer service that require manual message processing, so that developers can provide users with better services.
1. Obtain ACCESS_TOKEN
http request method: 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 |
Under normal circumstances, WeChat will return the following JSON data packet to the public account:
{"access_token":"ACCESS_TOKEN","expires_in":7200}
2. Send message
Send text message
<span $txt</span> = '<span { "touser":"oLVPpjqs9BhvzwPj5A-vTYAX3GLc", "msgtype":"text", "text": { "content":"Hello World" } }</span>'<span ; </span><span $access_token</span> = "NU7Kr6v9L9TQaqm5NE3OTPctTZx797Wxw4Snd2WL2HHBqLCiXlDVOw2l-Se0I-WmOLLniAYLAwzhbYhXNjbLc_KAA092cxkmpj5FpuqNO0IL7bB0Exz5s5qC9Umypy-rz2y441W9qgfnmNtIZWSjSQ"<span ; </span><span $url</span> = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".<span $access_token</span><span ; </span><span $result</span> = https_post(<span $url</span>,<span $txt</span><span ); </span><span var_dump</span>(<span $result</span><span ); </span><span function</span> https_post(<span $url</span>,<span $data</span><span ) { </span><span $curl</span> =<span curl_init(); curl_setopt(</span><span $curl</span>, CURLOPT_URL, <span $url</span><span ); curl_setopt(</span><span $curl</span>, CURLOPT_SSL_VERIFYPEER, <span FALSE</span><span ); curl_setopt(</span><span $curl</span>, CURLOPT_SSL_VERIFYHOST, <span FALSE</span><span ); curl_setopt(</span><span $curl</span>, CURLOPT_POST, 1<span ); curl_setopt(</span><span $curl</span>, CURLOPT_POSTFIELDS, <span $data</span><span ); curl_setopt(</span><span $curl</span>, CURLOPT_RETURNTRANSFER, 1<span ); </span><span $result</span> = curl_exec(<span $curl</span><span ); </span><span if</span> (curl_errno(<span $curl</span><span )) { </span><span return</span> 'Errno'.curl_error(<span $curl</span><span ); } curl_close(</span><span $curl</span><span ); </span><span return</span> <span $result</span><span ; }</span>
Send pictures (media_id needs to be uploaded first to get the picture)
<span $img</span> = '<span { "touser":"oLVPpjqs9BhvzwPj5A-vTYAX3GLc", "msgtype":"image", "image": { "media_id":"jViS8sQUXIh6rTdkz2qUOD5pvChYpp50i9rsLR4YnCm-pqdpiHhz6xbN2KAboScV" } }</span>';
==============================================
How to follow the Fangbei Studio WeChat public platform account:
1. WeChat address book-add friend-search public account-search for "Fangbei Studio"
2. WeChat address book-add friend-search Number - enter "pondbaystudio"
3. Use WeChat to scan the QR code below

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Thanks to netizens Qing Qiechensi, HH_KK, Satomi Ishihara and Wu Yanzu of South China for submitting clues! According to news on September 2, there are recent rumors that "iPhone 16 may not support WeChat." In response to this, a reporter from Shell Finance called Apple's official hotline. Apple's technical consultant in China responded that whether iOS systems or Apple devices can continue to use WeChat, and WeChat The issue of whether it can continue to be listed and downloaded on the Apple App Store requires communication and discussion between Apple and Tencent to determine the future situation. Software App Store and WeChat Problem Description Software App Store technical consultant pointed out that developers may need to pay fees to put software on the Apple Store. After reaching a certain number of downloads, Apple will need to pay corresponding fees for subsequent downloads. Apple is actively communicating with Tencent,

DeepSeek: A powerful AI image generation tool! DeepSeek itself is not an image generation tool, but its powerful core technology provides underlying support for many AI painting tools. Want to know how to use DeepSeek to generate images indirectly? Please continue reading! Generate images with DeepSeek-based AI tools: The following steps will guide you to use these tools: Launch the AI Painting Tool: Search and open a DeepSeek-based AI Painting Tool (for example, search "Simple AI"). Select the drawing mode: select "AI Drawing" or similar function, and select the image type according to your needs, such as "Anime Avatar", "Landscape"

Gate.io, a leading cryptocurrency trading platform founded in 2013, provides Chinese users with a complete official Chinese website. The website provides a wide range of services, including spot trading, futures trading and lending, and provides special features such as Chinese interface, rich resources and community support.

The OKX trading platform offers a variety of rates, including transaction fees, withdrawal fees and financing fees. For spot transactions, transaction fees vary according to transaction volume and VIP level, and adopt the "market maker model", that is, the market charges a lower handling fee for each transaction. In addition, OKX also offers a variety of futures contracts, including currency standard contracts, USDT contracts and delivery contracts, and the fee structure of each contract is also different.

Gate.io (Sesame Open Door) is the world's leading cryptocurrency trading platform. This article provides a complete tutorial on spot trading of Gate.io. The tutorial covers steps such as account registration and login, KYC certification, fiat currency and digital currency recharge, trading pair selection, limit/market transaction orders, and orders and transaction records viewing, helping you quickly get started on the Gate.io platform for cryptocurrency trading. Whether a beginner or a veteran, you can benefit from this tutorial and easily master the Gate.io trading skills.

Gateio Exchange app download channels for old versions, covering official, third-party application markets, forum communities and other channels. It also provides download precautions to help you easily obtain old versions and solve the problems of discomfort in using new versions or device compatibility.

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.

Learn to easily copy Xiaohongshu copywriting! This tutorial teaches you step by step how to quickly copy Xiaohongshu video copy, saying goodbye to tedious steps. Open the Xiaohongshu APP, find the video you like, and click on the [Copywriting] area below the video. Long press the copy text and select the [Extract Text] function from the pop-up options. The system will automatically extract the text, click the [Copy] button in the lower left corner. Open WeChat or other applications, such as Moments, long press the input box, and select [Paste]. Click Send to complete the copy. It's that simple!
