PHP code example of luanjinlong / youzan

1. Go to this page and download the library: Download luanjinlong/youzan library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luanjinlong / youzan example snippets

`


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);
    }
}

`
1. app('youzan')
2. app(Client::class)
3. 或者直接在控制器里面依赖注入 Long\Youzan\Open\Client


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);
    }
}

`


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);
    }
}