php版微信小店调用api示例代码
网络编程 2021-07-05 08:23www.168986.cn编程入门
这篇文章主要介绍了php版微信小店调用api用法,结合实例形式分析了微信小店API接口调用展示商品信息的基本操作技巧,需要的朋友可以参考下
本文实例讲述了php版微信小店调用api的方法。分享给大家供大家参考,具体如下:
刚开始调用微信小店api的时候,可能大家会遇到问题。系统总是提示system error,归根结底还是发送的参数不正确。
狼蚁网站SEO优化给出几个调用例子:
例子写得不全。
<?php function cUrlRequest($url,$data = null){ $curl = curl_init(); curl_set($curl, CURLOPT_URL, $url); curl_set($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_set($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)){ curl_set($curl, CURLOPT_POST, 1); curl_set($curl, CURLOPT_POSTFIELDS, $data); } curl_set($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } //获取所有商品 function gStateProduct($state = 0,$token){ //https://api.weixin.qq./merchant/getbystatus?aess_token=ACCESS_TOKEN //{"status": 0} // $AessToken = "xxxxxxxx"; $url = "https://api.weixin.qq./merchant/getbystatus?aess_token=".$token; //print_r($this->AessToken); $ResData = cUrlRequest($url,'{"status": '.$state.'}'); //特别注意这里,这个是json格式的。 echo "<pre>"; print_r( json_decode($ResData) ); } //获得所有分组 function getAllCategory($state = 0,$token) { $url = "https://api.weixin.qq./merchant/group/getall?aess_token=".$token; $ResData = cUrlRequest($url,'{"status": '.$state.'}'); echo "<pre>"; print_r( json_decode($ResData) ); } //根据分组id来获得商品信息 function getProductByGroudid($state = 0,$token) { $url = "https://api.weixin.qq./merchant/group/getbyid?aess_token=".$token; $ResData = cUrlRequest($url,'{"group_id": '.$state.'}'); echo "<pre>"; print_r( json_decode($ResData) ); } //获取aesstoken function getAessToken() { $appid = "your appid"; $appsecret = "your appsecret"; $url = "https://api.weixin.qq./cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret; $result = cUrlRequest($url); $jsoninfo = json_decode($result, true); $aess_token = $jsoninfo["aess_token"]; return $aess_token; } //根据product_id来获取单个商品 function getOneProductByid($state = 0,$token) { $url="https://api.weixin.qq./merchant/get?aess_token=".$token; $ResData = cUrlRequest($url,'{"product_id": "'.$state.'""}'); echo "<pre>"; print_r( json_decode($ResData) ); } $AessToken=getAessToken(); //gStateProduct(1,$AessToken); //getAllCategory(1,$AessToken); //getProductByGroudid(207061749,$AessToken); getOneProductByid("pf82VwN45zr8eOlur5mAiSTjg8WU",$AessToken);
更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家PHP程序设计有所帮助。
上一篇:PHP错误和异常处理功能模块示例
下一篇:php实用代码片段整理
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程