Coder Social home page Coder Social logo

laravel-wechat's Issues

服务器token验证

我的控制器:
public function serve()
{
Log::info('request arrived.'); # 注意:Log 为 Laravel 组件,所以它记的日志去 Laravel 日志看,而不是 EasyWeChat 日志
$wechat = app('wechat');
//return $wechat;
app('wechat')->server->setMessageHandler(function($message){
return "欢迎关注 overtrue!";
});
Log::info('return response.');
return app('wechat')->server->serve();
}
我的route:Route::any('/weixin', 'WeixinController@serve');
我的middle:
protected $except = [
'weixin',
];
我的报告:BadRequestException in Guard.php line 317:
Invalid request.
我的日记:所有参数key,id等传输正确
腾讯验证:token验证错误

5.4 似乎不可用

local.ERROR: Overtrue\Socialite\AuthorizeFailedException: Authorize Failed: {"errcode":40013,"errmsg":"invalid appid, hints: [ req_id: tQPTEa0975s109 ]"} in /mnt/sdc/dindon_front/vendor/overtrue/socialite/src/Providers/AbstractProvider.php:409

Oauth 中间件, 网页授权的一直报这个错误。
如果直接使用 overtrue/wechat, 则会提示 secret 无效

使用微信对账单下载时候报错

php 版本:5.5.30
"overtrue/laravel-wechat":版本:3.0.6

使用微信对账单下载时候报错
$result=$payment->downloadBill(intval($request->input('date')));

ErrorException in XML.php line 37: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found

in XML.php line 37
at HandleExceptions->handleError('2', 'simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '&lt;' not found', '/www/wwwroot/laravel/vendor/overtrue/wechat/src/Support/XML.php', '37', array('xml' => object(Stream)))
at simplexml_load_string('交易时间,公众账号ID,商户号,子商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,总金额,企业红包金额,微信退款单号,商户退款单号,退款金额,企业红包退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率 `2016-03-14

如果在回调方法里使用 Model::create() 函数,就会报异常

大神你好
实例

//收到订阅事件
 $server->on('event','subscribe',function($event){
            $openID = $event->FromUserName;
            $weChatUser = Wechat::user();
            $userInfo = $weChatUser->get($openID)->toArray();
            Users::create($userInfo);
           return Message::make('text')->content('欢迎关注');
)}

就会报错:

FatalErrorException in Response.php line 0:
Method Overtrue\Wechat\Server::__toString() must not throw an exception

经过各种测试,只要是使用 Model::create() 方法就会这样, 在消息接收里也是这样。
我的Laravel 版本是 5.1
实在解决不了了,不知道哪里出的错。大神帮帮忙啊,多谢~~

关于协作开发的问题

最近发现一个问题。由于需要注册 ServiceProvider,导致一个问题。
即:最初引用本插件的开发者在config/app.php中注册了ServiceProvider,将代码提交到版本库后别的开发者更新下来,由于laravel默认是将vendor加入了git的忽略列表,因此其他开发者需要执行一次composer update才可能将插件安装,但是由于config/app.php已经注册了Overtrue\LaravelWechat\ServiceProvider,但此时Overtrue\LaravelWechat\ServiceProvider是不存在的,那么composer update将会报错,导致update无法执行。
对于这个问题,是否有更好的解决方案呢?

通过alias方式获取实例发生exception

具体配置
config providers:
Overtrue\LaravelWechat\ServiceProvider::class,

alias:
'Wechat' => Overtrue\LaravelWechat\Facade::class,

代码:
$wechat = Wechat::server();
$payment = $wechat->payment;

异常情况:
2016-07-24 22 05 55

js支付创建订单一直失败

代码如下:

            $orderAttributes = [
                'trade_type' => 'JSAPI',
                'body' => '支付订单',
                'out_trade_no' => Carbon::now()->format('ymdHisU'),
                'total_fee' => bcmul($product->combo->price,100,0),
                'notify_url' => url('xxx'),
                'openid' => \Auth::user()->openid,
                'attach' => sprintf('PAPA_%s_%s',$product->id,bcmul($product->combo->price,100,0)),
                'device_info' => 'WEB',
                'spbill_create_ip' => '8.8.8.8'
            ];
            $order = new Order($orderAttributes);
            $result = $wechat->payment->prepare($order);var_dump($result);

输出:

object(EasyWeChat\Support\Collection)#323 (1) {
["items":protected]=>
array(1) {
[0]=>
bool(false)
}
}
远端 HTTP CODE 200。response body 为空

Laravel5.3下应该如何在路由中添加中间件呢?

在路由中添加中间件:
5.2是这样的,5.3的路由该如何配置呢?
以 5.2 为例:

Route::group(['middleware' => ['web', 'wechat.oauth']], function () {
    Route::get('/user', function () {
        $user = session('wechat.oauth_user'); // 拿到授权用户资料

        dd($user);
    });
});

安装时出错

作者你好,我用composer安装时出现了以下问题,搜寻网上没有找到解决办法,请教如何解决

./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
- Conclusion: don't install overtrue/laravel-wechat 3.0.1
- Conclusion: remove symfony/http-foundation v2.6.13
- Installation request for overtrue/laravel-wechat ~3.0 -> satisfiable by overtrue/laravel-wechat[3.0, 3.0.1].
- Conclusion: don't install symfony/http-foundation v2.6.13
- overtrue/laravel-wechat 3.0 requires overtrue/wechat ~3.0 -> satisfiable by overtrue/wechat[3.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4].
- overtrue/wechat 3.0 requires overtrue/socialite ^1.0 -> satisfiable by overtrue/socialite[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7].
- overtrue/wechat 3.0.1 requires overtrue/socialite ^1.0 -> satisfiable by overtrue/socialite[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7].
- overtrue/wechat 3.0.2 requires overtrue/socialite >=1.0.7 -> satisfiable by overtrue/socialite[1.0.7].
- overtrue/wechat 3.0.3 requires overtrue/socialite >=1.0.7 -> satisfiable by overtrue/socialite[1.0.7].
- overtrue/wechat 3.0.4 requires overtrue/socialite >=1.0.7 -> satisfiable by overtrue/socialite[1.0.7].
- overtrue/socialite 1.0.0 requires symfony/http-foundation ~2.8|~2.7 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3].
- overtrue/socialite 1.0.1 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- overtrue/socialite 1.0.2 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- overtrue/socialite 1.0.3 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- overtrue/socialite 1.0.4 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- overtrue/socialite 1.0.5 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- overtrue/socialite 1.0.6 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- overtrue/socialite 1.0.7 requires symfony/http-foundation ~2.8|~2.7|~3.0 -> satisfiable by symfony/http-foundation[v2.7.0, v2.7.1, v2.7.10, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2, v2.8.3, v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- Can only install one of: symfony/http-foundation[v2.7.0, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.1, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.10, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.2, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.3, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.4, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.5, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.6, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.7, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.8, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.7.9, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.8.0, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.8.1, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.8.2, v2.6.13].
- Can only install one of: symfony/http-foundation[v2.8.3, v2.6.13].
- Can only install one of: symfony/http-foundation[v3.0.0, v2.6.13].
- Can only install one of: symfony/http-foundation[v3.0.1, v2.6.13].
- Can only install one of: symfony/http-foundation[v3.0.2, v2.6.13].
- Can only install one of: symfony/http-foundation[v3.0.3, v2.6.13].
- Installation request for symfony/http-foundation == 2.6.13.0 -> satisfiable by symfony/http-foundation[v2.6.13].

下载素材的出错

$media->download($value, $filename);
下载素材时出现下面问题。

[2015-04-30 18:52:31] local.ERROR: exception 'Overtrue\Wechat\Exception' with message '[Wechat][43002] 43002 需要POST请求' in /var/www/meishenghuo/web/vendor/overtrue/wechat/src/Wechat/Http.php:91
Stack trace:
#0 /var/www/meishenghuo/web/vendor/overtrue/wechat/src/Wechat/Utils/Http.php(65): Overtrue\Wechat\Http->request('http://file.api...', 'GET', Array, Array)
#1 /var/www/meishenghuo/web/vendor/overtrue/wechat/src/Wechat/Media.php(251): Overtrue\Wechat\Utils\Http->get('http://file.api...', Array)
#2 /var/www/meishenghuo/web/app/Http/Controllers/RepairsController.php(104): Overtrue\Wechat\Media->download('Gr31ecyJCdFhQK2...', '/var/www/meishe...')

服务器验证问题

我用laravel 5.1.11的版本,在微信公众平台的服务器配置中,做服务器验证时总提示Token验证失败,验证要怎么操作,大神指教!!!!

发送模板消息有问题

感谢作者贡献此库,之前一直node,现在发现PHP库发送模板消息有点问题:

  1. url是必填项,node是非必填的
  2. \n字符无效,node是有效的

这两个部分对我们现在的应用场景蛮重要的,请问下应该修改库的什么部分来修复这两个问题呢,多谢!

当使用 Laravel cache 时,verify ticket 无法缓存

如题,我看过代码,原因应该是VerifyTicket 的 cache 的 save() 方法没有给时间,即为 0,而 Laravel 的cache 的 put 方法是不考虑是不是 0 的,必须用 forever 方法。代码片段都在下面供参考。
测试过 database 和 redis 两个 cache driver。

VerifyTicket

    public function cache(Collection $message)
    {
        return $this->getCache()->save(
            $this->getCacheKey(),
            $message->get($this->ticketXmlName)
        );
    }

DatabaseStore

    public function put($key, $value, $minutes)
    {
        $key = $this->prefix.$key;

        // All of the cached values in the database are encrypted in case this is used
        // as a session data store by the consumer. We'll also calculate the expire
        // time and place that on the table so we will check it on our retrieval.
        $value = $this->encrypter->encrypt($value);

        $expiration = $this->getTime() + (int) ($minutes * 60);

        try {
            $this->table()->insert(compact('key', 'value', 'expiration'));
        } catch (Exception $e) {
            $this->table()->where('key', $key)->update(compact('value', 'expiration'));
        }
    }

    public function forever($key, $value)
    {
        $this->put($key, $value, 5256000);
    }

RedisStore

    public function put($key, $value, $minutes)
    {
        $this->connection()->setex(
            $this->prefix.$key, (int) max(1, $minutes * 60), $this->serialize($value)
        );
    }

    public function forever($key, $value)
    {
        $this->connection()->set($this->prefix.$key, $this->serialize($value));
    }

Config is not loaded by default

Hello,

I'm trying to seta OAuth with WeChat on my app.
It seems the config file was not loaded, let see :

In the OAuthAuthenticate middleware, in the handle() function, you create a new $wechat like this :

$wechat = app('EasyWeChat\\Foundation\\Application');

But this error was thrown :

Unresolvable dependency resolving [Parameter #0 [ <required> $config ]] in class EasyWeChat\Foundation\Application

If I set the default param to empty array, and load the config file after like this :

public function __construct($config)
    {
        parent::__construct();
        $config = config('wechat');

        $this['config'] = function () use ($config) {
            return new Config($config);
        };

        if ($this['config']['debug']) {
            error_reporting(E_ALL);
        }

        $this->registerProviders();
        $this->registerBase();
        $this->initializeLogger();

        Log::debug('Current configuration:', $config);
    }

It works well.

PR was made : #30

composer update 之后报错

PHP Parse error: syntax error, unexpected '{' in /home/wwwroot/weixin.xxx.com/vendor/overtrue/laravel-wechat/src/ServiceProvider.php on line 62

使用composer连接不上去

以下是我们运行的结果

Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package overtrue/laravel-wechat could not be found in any version, there may be a typo in the package name.
Problem 2
- laravel/framework v5.0.28 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- laravel/framework v5.0.28 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- Installation request for laravel/framework == 5.0.28.0 -> satisfiable by laravel/framework[v5.0.28].

Potential causes:

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

请问为什么取不到$wechat呢

$wechat = App::make('wechat');
$wechat->on('message', ...);

在laravel 5 中报错 :[2015-04-19 03:19:04] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Undefined class constant 'User'' in /var/www/wechat/app/Http/Controllers/WechatController.php:22

请问这是为什么呢?

关于在CSRF中排除微信路由的做法疑问

看到你文档写的做微信开发的时候必须要在CSRF验证中去除微信的路由,但是这样做我在测试中发现在Laravel5.2版本中是有问题的,原因如下:
根据Laravel文档我们可以设置$excerpt属性来排除部分不需要csrf的路由,但是我实际测试发现设置了也没用。查看csrf的源码如下:

public function handle($request, Closure $next)
    {
        if (
            $this->isReading($request) ||
            $this->runningUnitTests() ||
            $this->shouldPassThrough($request) ||
            $this->tokensMatch($request)
        ) {
            return $this->addCookieToResponse($request, $next($request));
        }

        throw new TokenMismatchException;
    }

从以上源码可以看到,if条件中四个只要满足一个就会执行这个中间件,第一个$this->isReading方法的源码:

protected function isReading($request)
    {
        return in_array($request->method(), ['HEAD', 'GET', 'OPTIONS']);
    }

可以看到如果是HEAD,GET,OPTIONS请求方法就不会执行$this->shouldPassThrough这个方法来判定当前是否需要过CSRF中间件了。而且微信是GET和POST请求都有,所以我觉得在csrf中排除微信相关的路由这个做法有点不适合,你觉得呢?

Class wechat.server does not exist

Class wechat.server does not exist
很奇怪,其他都使用.唯独"wechat.server"提示不存在.

将下面代码,写到自带的"App\Providers\AppServiceProvider"却能使用.

$this->app->singleton(['Overtrue\\Wechat\\Server' => 'wechat.server'], function($app){
    return new WechatServer(config('wechat.app_id'), config('wechat.token'), config('wechat.encoding_key'));
});

这是为什么???

说明文档更新

在5.2中应该是,请更新readme谢谢
'Wechat' => Overtrue\LaravelWechat\Facade::class,

微信支付统一下单结果只有一个false

根据文档执行到$result = $payment->prepare($order);后,
打印$result的值,一直是返回只有false:
Collection {#944
#items: array:1 [
0 => false
]
}
也没有任何提示错误?还没找到是什么原因

似乎Facade不起作用

Hi, 我按照手册引入了相关的provider和facade。但是在controller中使用Wechat::时,报找不到相关的类。很迷惑哟~

Illegal offset type in unset with Laravel 5.4

Laravel->5.4 fresh installed.
Laravel->wechat 3.2.4.
Project crashed if add Overtrue\LaravelWechat\ServiceProvider::class to providers array.

    [ErrorException]
    Illegal offset type in unset

laravel-debugbar兼容问题

文档里说 “如果你用了 laravel-debugbar,请禁用或者关掉,否则这模块别想正常使用!!!”,请问不能同时使用debugbar的原因是什么?

中间件授权 40001

使用中间件授权的方式。

某些手机授权不成功,拿不到openid.

user对象:

{
  "id": null,
  "name": null,
  "nickname": null,
  "avatar": null,
  "email": null,
  "original": {
    "errcode": 40001,
    "errmsg": "invalid credential, access_token is invalid or not latest, hints: [ req_id: aGWfma0000ns83 ]"
  },
  "token": {
    "access_token": "p5rApFmJHpEzw37UIlwQNMnTMCxzksyrnp1fQGbcAxhCfrH5wGqFHI84SF6dDHhPCMs6J9DITF2br6gOxEEY2Hkzuw5qPjSnnuoK5uiw1zo",
    "expires_in": 7200,
    "refresh_token": "W9OZ31vZK0r5gCeMWiEOgXac-d23-CQZ3dBteZ93XWiqUAxgei9R9swNUKtYqdc9B9Zr98olV35LDsyaHoOwPxsHm61a-S7xW1WfIE8-NX0",
    "openid": "oN-UTxF1XDoe-cs2MxUfedxUdX2Q",
    "scope": "snsapi_userinfo"
  }
}

请问一下微信的测试账号出现:该公众号暂时无法提供服务,请稍后再试

\x0A\x0A1429670043\x0A\x0A\x0A6140386078960211765\x0A" 500 12378 "-" "Mozilla/4.0" - "0.070,0.138" 网上说是: 请开发者注意,一旦遇到以下情况,微信都会在公众号会话中,向用户下发系统提示“该公众号暂时无法提供服务,请稍后再试”: 1、开发者在5秒内未回复任何内容 2、开发者回复了异常数据,比如JSON数据等 请问一下不知道是否是库本身原因还是微信这边的问题呢?

微信公众号动态配置无效

微信公众号动态配置无效....
//
$wechatConfig = DB::table('wx_config')->first();
//...
//
$wechat = app('wechat', $wechatConfig);

$wechat['config']的值仍是config/wechat.php配置文件中的值,并不是传过去的$wechatConfig

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.