微信公眾平臺接口實現(xiàn)發(fā)送信息代碼實例
當(dāng)前位置:點晴教程→知識管理交流
→『 技術(shù)文檔交流 』
微信是一種生活方法,現(xiàn)在越來越多的網(wǎng)站用戶需要實現(xiàn)線上線下互動功能,網(wǎng)站要實現(xiàn)與微信對接,那就涉及到公眾平臺的開發(fā),至于怎么申請公眾平臺在此我就不多說了,只要進(jìn)入騰訊的微信平臺網(wǎng)站(weixin.qq.com),根據(jù)流程,即可申請好.重點是如何實現(xiàn)簡單的功能開發(fā).
![]() 通過微信公眾賬號及密碼進(jìn)入,點擊"高級功能"-->開發(fā)模式(進(jìn)入)-->即可查看到AppId及AppSecret ![]() < ?php $AppId="wxde9e41f7c2d3xxxx";填入上圖所示的appId號 $AppSecret="5615c25ff32169645fc6443f4dabxxxx"; $url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$AppId}&secret={$AppSecret}"; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $a =curl_exec($ch); $strjso=json_decode($a); $token = $strjson->access_token; $post=' { "touser":"OPENID", //填入切確的用戶ID,即經(jīng)過微信加密了的. "msgtype":"text", "text": { "content":"歡迎關(guān)注新東方優(yōu)能中學(xué)教育微信,好禮享不停!" } }'; $url="https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}"; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFILEDS,$post); curl_exec($ch); curl_close($ch); ?> 該文章在 2014/12/3 0:25:03 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |