时时商务社区
标题:
php版微信小店调用api示例代码
[打印本页]
作者:
新格网络
时间:
2018-2-14 05:30
本文实例讲述了php版微信小店调用api的方法。分享给大家供大家参考,具体如下:
刚开始调用微信小店api的时候,可能大家会遇到问题。系统总是提示system error,归根结底还是发送的参数不正确。
下面给出几个调用例子:
例子写得不全。
AccessToken);
$ResData = cUrlRequest($url,'{"status": '.$state.'}'); //特别注意这里,这个是json格式的。
echo "";
print_r( json_decode($ResData) );
}
//获得所有分组
function getAllCategory($state = 0,$token)
{
$url = "https://api.weixin.qq.com/merchant/group/getall?access_token=".$token;
$ResData = cUrlRequest($url,'{"status": '.$state.'}');
echo "";
print_r( json_decode($ResData) );
}
//根据分组id来获得商品信息
function getProductByGroudid($state = 0,$token)
{
$url = "https://api.weixin.qq.com/merchant/group/getbyid?access_token=".$token;
$ResData = cUrlRequest($url,'{"group_id": '.$state.'}');
echo "";
print_r( json_decode($ResData) );
}
//获取accesstoken
function getAccessToken()
{
$appid = "your appid";
$appsecret = "your appsecret";
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret;
$result = cUrlRequest($url);
$jsoninfo = json_decode($result, true);
$access_token = $jsoninfo["access_token"];
return $access_token;
}
//根据product_id来获取单个商品
function getOneProductByid($state = 0,$token)
{
$url="https://api.weixin.qq.com/merchant/get?access_token=".$token;
$ResData = cUrlRequest($url,'{"product_id": "'.$state.'""}');
echo "";
print_r( json_decode($ResData) );
}
$AccessToken=getAccessToken();
//gStateProduct(1,$AccessToken);
//getAllCategory(1,$AccessToken);
//getProductByGroudid(207061749,$AccessToken);
getOneProductByid("pf82VwN45zr8eOlur5mAiSTjg8WU",$AccessToken);
更多关于PHP相关内容感兴趣的读者可查看本站专题:《
PHP微信开发技巧汇总
》、《
PHP编码与转码操作技巧汇总
》、《
PHP网络编程技巧总结
》、《
PHP基本语法入门教程
》、《
php字符串(string)用法总结
》、《
php+mysql数据库操作入门教程
》及《
php常见数据库操作技巧汇总
》
希望本文所述对大家PHP程序设计有所帮助。
您可能感兴趣的文章:
PHP版微信公众平台红包API
微信支付扫码支付php版
php版微信公众平台回复中文出现乱码问题的解决方法
php版微信公众号自定义分享内容实现方法
php版微信公众平台之微信网页登陆授权示例
php版微信开发之接收消息,自动判断及回复相应消息的方法
PHP版微信第三方实现一键登录及获取用户信息的方法
php版微信公众号接口实现发红包的方法
PHP版微信小店接口开发实例
php版微信小店API二次开发及使用示例
php版微信返回用户text输入的方法
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2