PHP根據微信開放文檔開發的幾個DEMO實例,本人正在做一款自動生成文章,群發圖文消息給關注的用戶,有公眾號粉絲的朋友開發好自動賺流量主廣告推廣費
目前用PHP原生開發的7個DEMO,每個都帶有文檔地址和接口調用地址,這些接口正在開發中,后面下載的用戶免費下載
1、獲取公眾號已創建的標簽 biaoqian_lists.php
//文檔:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
//接口調用:https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN
2、新增臨時素材
//文檔:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html
//接口調用:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
3、上傳圖文消息內的圖片獲取URL(上傳圖文消息內的圖片獲取URL,在素材庫里看不到,不占用公眾號素材庫限制10000個) sucai_message_inner_pic.php
//文檔:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html
//接口調用:https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
4、新增文章 sucai_news_add.php
//文檔:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html
//接口調用:https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN
function get_access_token() {
$appid = 'wx0fa9475891599';
$secret = 'f96dbe01750027fdc0e81228effa';
$url_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret . "";
$curl_token = curl_get($url_token);
//print_r($curl_token);exit;
$access_token = $curl_token['access_token'];
return $access_token;
}
$access_token = get_access_token(); //獲取access_token
$url_material = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=" . $access_token . ""; //調用該接口需https協議
//echo iconv('UTF-8', 'GB2312', '站長貨小小a');exit;
$media = '{
"articles": [{
"title": "素材火",
"thumb_media_id": "x5uMq7UJhIdhGdADoIKzJsiAfZkQ4BiIcZQA-klCdp8",
"author": "素材火",
"digest": "素材火",
"show_cover_pic": 1,
"content": "PHP微信社區團購生鮮商城系統源碼蔬菜百貨超市連鎖微商城源碼",
"content_source_url": "https://www.sucaihuo.com/source/12434.html",
},
//若新增的是多圖文素材,則此處應還有幾段articles結構
]
}';
$curl_upload = curl_post($url_material, 'post', $media);
print_r($curl_upload);
5、新增永久圖文素材(在素材庫里可查看,官方限制10000個)sucai_pic_add.php
//文檔:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html
//接口調用:https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE
6、獲取用戶信息 user_info.php
//接口調用:https://api.weixin.qq.com/cgi-bin/user/info?access_token=$access_token&openid=$openid&lang=zh_CN
7、獲取用戶openid user_openid.php
//文檔:https://developers.weixin.qq.com/doc/offiaccount/User_Management/Getting_a_User_List.html
//接口調用:https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID