youzan-laravel
$ composer require luanjinlong/youzan
- 组件已经默认为你获取
access_token
无需获取
<?php
namespace App\Http\Controllers;
use Long\Youzan\RequestMethod\Users;
class UsersController extends Controller
{
/**
* @param Users $users
*/
public function index(Users $users)
{
$response = $users->getUsersWeixinFollowerSearch('2018-09-10','2018-09-11',10);
dd($response);
}
}
其实本质是调用的 Long\Youzan\Open\Client
这个类,调取这个类的方式有以下几种
1. app('youzan')
2. app(Client::class)
3. 或者直接在控制器里面依赖注入 Long\Youzan\Open\Client
<?php
namespace App\Http\Controllers;
use Long\Youzan\Open\Client;
class TestController extends Controller
{
/**
* @param Client $client
*/
public function index(Client $client)
{
$token = $client->getAccessToken();
dd($token);
}
}
<?php
namespace App\Http\Controllers;
use Long\Youzan\Open\Client;
class TestController extends Controller
{
// 根据关注时间段批量查询微信粉丝用户信息
const USERS_WEIXIN_FOLLOWER_SEARCH = 'youzan.users.weixin.followers.info.search';
const API_VERSION = '3.0.0';
/**
* @param Client $client
* @return array
*/
public function index(Client $client)
{
$my_params = [
'start_follow' => '2018-09-11',
'page_size' => 10,
'end_follow' => '2018-09-12',
];
return $client->post(self::USERS_WEIXIN_FOLLOWER_SEARCH, self::API_VERSION,$my_params);
}
}
The MIT License. Please see License File for more information.