thenbsp / wechat Goto Github PK
View Code? Open in Web Editor NEW微信公众平台第三方 SDK 开发包,优雅、健壮,可扩展,遵循 PSR 开发规范。
License: MIT License
微信公众平台第三方 SDK 开发包,优雅、健壮,可扩展,遵循 PSR 开发规范。
License: MIT License
导致无法开发,希望尽快上传1.1.7的文档
subcribe
unsubcribe
写成subscribe和unsubscribe了,望修复
加油啊!模版消息
是不是像模板消息那样缺少发送的方法呀
请问现在composer安装是不是有问题,没办法下载下来
看了一下,基本上是接口的封装,那大神有没有一个Demo可以让我这种小白可以理解这个SDK的使用方法呢?
我是用在Yii2这个框架中,感觉您的代码还是挺易读的,但是无从下手。
希望增加小程序相关的接口
以下方法还在规划中,还没有提交至 github。
$optionsResolver 在实际应用中一般以配置文件的形式存在,因此有必要将这些文件单独分离出来,不必在每次下单时去获取这些参数,并且该方法可满足在多个商户之间切换的需求:
$optionsResolver = array(
'appid' => 'you appid',
'appsecret' => 'you appsecret',
'mch_id' => 'you mch_id',
'mch_key' => 'you mch_key',
'notify_url' => 'notify_url_a.php'
);
配置商品基本参数,这里如果出现和 $optionsResolver 相同的参数前者将会被覆盖,这种方式在有些情况下很有用,比如有一款特殊的商口需要通知另一个特定接口时,比如示列中的 notify_url 项,最终请求 unifiedorder 接口会提交 notify_url_b.php 而不是 notify_url_a.php:
$unifiedorder = new Unifiedorder($optionsResolver);
$unifiedorder->body('iphone 6 plus');
$unifiedorder->out_trade_no(date('Y-m-dHis').mt_rand(10000, 99999));
$unifiedorder->total_fee('650000'); // 单位为 “分”
$unifiedorder->openid('Openid form session');
$unifiedorder->notify_url('notify_url_b.php');
配置完统一下单接参数后,调用 getResponse() 方法将发起对 unifiedorder 接口的调用,响应结果将以 Object 的形式返回,如果接口调用出错,将抛出一个 UnifiedorderException 异常:
try {
$response = $unifiedorder->getResponse();
} catch (UnifiedorderException $e) {
exit($e->getMessage());
}
var_dump($response);
在配置完统一直单的参数后,可以通过 getParams() 方法来查看当前参数是否正确(或缺少):
$params = $unifiedorder->getParams();
var_dump($params);
Fatal error: Uncaught exception 'Exception' with message 'api unauthorized, hints: [ req_id: dIaOLa0186s154 ]' in /www/wx/vendor/thenbsp/wechat/src/OAuth/AccessToken.php:68 Stack trace: #0
Uncaught exception 'Shopnc\Exception'
with message 'Class Error: cannot autoload
class: Thenbsp\Wechat\OAuth\Client
命名空间
use Shopnc\Tpl;
use Thenbsp\Wechat\OAuth\Client;
$client = new Client($this->appid , $this->secret);
if( !isset($_GET['code']) ) {
header('Location: '.$client->getAuthorizeUrl());
}
echo 1111;die;
代码使用例子的
$config = new PayChoose($unifiedorder);
方式
微信点击支付时候报
调用支付jsapi缺少参数appld
希望考虑一下accesstoken已有中控的情形,
这种情况是不需要这边处理accesstoken的
项目开发到现在,才发现你写的微信支付通知,需要自己去签名认证
调用提示
Scope 参数错误或没有 Scope 权限
Parse error: syntax error, unexpected '[', expecting ')' in wechat/vendor/react/promise/src/functions.php on line 68
Conclusion: remove symfony/http-foundation v5.1.2
- Conclusion: don't install symfony/http-foundation v5.1.2
- thenbsp/wechat v2.1.0 requires symfony/http-foundation ~3.4|~4.0 -> satisfiable
为什么用统一下单 jsapi 签名错误。
看到目前最新的版本中Util/SignGenerator工具类已经没有了,想问下 @thenbsp 这块是否在未来的版本中也不会再加入回来了呢?
https://github.com/thenbsp/wechat/blob/master/src/Util/OptionValidator.php
为什么要有Symfony
赶紧自己实现一个,跟Symfony去藕啊!!!!!!!!!!!
Fatal error: Class 'Doctrine\Common\Collections\ArrayCollection' not found
请问,这是需要第三方库吗?
初次使用,非常感谢作者 ,使用过程中遇到了各种问题,还好都解决了。
发现了一个小问题,
https://github.com/thenbsp/wechat/blob/master/src/Wechat/Jsapi.php addApi 方法的递归函数有一点小问题,导致注入权限为数组时,无法正常工作
在微信中,签名是指对一组 QueryString 进行一定格式的排序,加密后的结果,大多数情况下, QueryString 将包含 appid
、timestamp
、nonce_str
等信息。
https://github.com/thenbsp/wechat/blob/master/Util/SignGenerator.php
基本示例一:
use Thenbsp\Wechat\Util\SignGenerator;
$signGenerator = new SignGenerator();
$signGenerator->addParams('appid', 'your are appid');
$signGenerator->addParams('timestamp', time());
$signGenerator->addParams('nonce_str', 'your are random string');
$result = $signGenerator->getResult();
var_dump($result);
以上结果等同于:
$appid = 'your are appid';
$timestamp = time();
$nonce_str = 'your are random string';
$string = 'appid='.$appid.'×tamp='.$timestamp .'&nonce_str='.$nonce_str ;
$result = md5($string);
var_dump($result);
// 暂时支持 sha1/md5(默认)
$signGenerator->setHashType('sha1');
$signGenerator->setUpper(true);
如题
Using version dev-master for thenbsp/wechat
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package thenbsp/wechat No version set (parsed as 1.0.0) is s
atisfiable by thenbsp/wechat[No version set (parsed as 1.0.0)] but these conflic
t with your requirements or minimum-stability.
Installation failed, reverting ./composer.json to its original content.
支付通知貌似没有验签~~
这个问题怎么解决呢?证书要怎么弄?
我开发阶段提示ip不在白名单的话我可以去微信公众平台后台添加,但是上线了怎么处理啊,不可能每个人的ip都添加吧
请问这个sdk对PHP版本最低要求是多少?5.3可以运行吗?老项目需要使用啊。。
关注时,服务器返回的数据:
1447921517
相关代码:
case ($this->_option['Event'] === 'subscribe') :
return array_key_exists('EventKey', $this->_option) ?
Event::EVENT_QRCODE_UNSUBSCRIBE : Event::EVENT_SUBSCRIBE;
break;
这里的逻辑,是返回了Event::EVENT_QRCODE_UNSUBSCRIBE。
是不是微信的数据变了,你没有及时更新呢?
这是我的代码,麻烦大神给处理一下 thinkyou
getAccessToken($code); var_dump($accessToken);建议加上国家三级区域 = addressCountiesThirdStageName
微信的命名规则很niubility
在thinkphp框架中怎么监听关注事件啊?我试了一下午没结果。
if( $notify->containsKey('out_trade_no') ) {
// 失败时必需返回,否则微信服务器将重复提交通知
$notify->fail('Invalid Request');
}
这个out_trade_no
字段应该都在吧,如果你这边发送fail不就不对了吗?!
对于我这样的菜鸟来说,实在是不会用....
微信一直小调整不断,这个sdk虽然强大但是会不会有功能已经失效了?
getAccessToken 一直返回 false 有什么解决办法吗?
你好,请教,微信开发平台,网站扫码登录,授权回调域为二级域名 xxx.com,请问该应用是否支持 xxx.xxx.com 三级域名。如果支持,对于不同的三级域名,比如a.xxx.com和b.xxx.com 同一用户返回的access_token是否相同。如果不支持,修改授权回调域后,修改前后,同一用户返回的access_token是否相同。
也遇到这个总是 不管是手动设置
还是第二个参数传进去
都在报错。
如果用户 授权后 然后点击授权页 就会出现异常
据了解 这是说code 不能重复使用
《code been used, hints: [ req_id: TlyhvA0845th13 ]》
在调用过程中的
Thenbsp\Wechat\OAuth\AbstractClient->getAccessToken('011h65fm0KiPfo1...')
Exception: Invalid Authentication State "STATE" in thenbsp/wechat/src/OAuth/AbstractClient.php:113
请问什么原因??Thanks
请教,在用户静默授权时,有没有遇到过code为空的情况,这个问题偶尔会出现
[0] Exception in AbstractClient.php line 113
Invalid Authentication State "NxVaLjsuw62Pl0dX"
public function getAccessToken($code, $state = null)
{
if (null === $state && !isset($_GET['state'])) {
throw new \Exception('Invalid Request');
}
// http://www.twobotechnologies.com/blog/2014/02/importance-of-state-in-oauth2.html
$state = $state ?: $_GET['state'];
if (!$this->stateManager->isValid($state)) {
throw new \Exception(sprintf('Invalid Authentication State "%s"', $state));
}
$query = array(
'appid' => $this->appid,
'secret' => $this->appsecret,
'code' => $code,
'grant_type' => 'authorization_code'
);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.