In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the PHP version of the WeChat store interface development example analysis, the article is very detailed, has a certain reference value, interested friends must read!
These are as follows:
First of all, you can go to the API interface developed by the next store. Because all the WeChat store interface data format parameters API manuals below have ready-made ones, you can use them directly. The code below is good.
Here you can download the API documentation of Microshop
Here, let's take the query product as an example
//The first step is to get the code of access_token. Here, I have made a storage table for token because token has restrictions. Private function access_token(){appid=shopappid;//When copying, write appid as your own apps=shop_appsecret;//When copying, write appsecret as your own wxuserdb=M ('Wxuser ′);//You can remove this note!! wxuser=wxuserdb−>where(array('appid′=>appid))->find();//get access_tokenif(wxuser[′atupdatetime′]==′′|| intval(time())−intval(wxuser['atupdatetime'])>4000|| $wxuser['access_token']==""){ $url = "https://api.weixin.qq.com/cgi-bin/token? grant_type=client_credential&appid=".$ appid. "&secret=".$ apps; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $jsoninfo = json_decode($output, true); $access_token = $jsoninfo["access_token"]; $wxuser['access_token']=$access_token; $wxuser['atupdatetime']=time(); $wxuserdb->where(array('appid'=>$appid))->save($wxuser); }else{ $access_token = $wxuser['access_token']; } return $access_token;}
So I encapsulated it here, and it's getting data through interfaces.
Wrapper PHP curl() method
private function get_res(url,data){ch=curlinit();curlsetopt(ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt(ch,CURLOPTSSLVERIFYHOST,FALSE);curlsetopt(ch, CURLOPT_URL, url);curlsetopt(ch, CURLOPT_POSTFIELDS, data);curlsetopt(ch, CURLOPT_RETURNTRANSFER, true);output=curlexec(ch);curl_close(ch);jsoninfo = json_decode(output,true);returnjsoninfo;}/** * productid get productinfo Get product information according to id */private function get_product_info(){wxtoken=this->access_token();//get tokenproductid=′ pP3K2s25zDRY50 n3nLCKqZvPzINM′;//product idurl = "https://api.weixin.qq.com/merchant/get? access_token=".wxtoken;//Here is the interface address for querying commodity information by commodity id. data='{ "product_id": "'.product_id. '"} '; echothis->get_res(url,data);//exit via PHP curl() method wrapped earlier;}
Friends who need to take it directly only need to change appid and secret
Other interfaces only need to change the interface address and the transmitted data
The above is "PHP version of the WeChat store interface development example analysis" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.