GetVfWebQQRequest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of the slince/smartqq package.
4
 *
5
 * (c) Slince <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Slince\SmartQQ\Request;
12
13
use GuzzleHttp\Psr7\Response;
14
use Slince\SmartQQ\Exception\RuntimeException;
15
16
class GetVfWebQQRequest extends Request
17
{
18
    protected $uri = 'http://s.web2.qq.com/api/getvfwebqq?ptwebqq={ptwebqq}&clientid=53999199&psessionid=&t=0.1';
19
20
    protected $referer = 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1';
21
22
    public function __construct($ptWebQQ)
23
    {
24
        $this->setToken('ptwebqq', $ptWebQQ);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public static function parseResponse(Response $response)
31
    {
32
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
33
        if (!isset($jsonData['result']['vfwebqq'])) {
34
            throw new RuntimeException('Can not find argument [vfwebqq]');
35
        }
36
37
        return $jsonData['result']['vfwebqq'];
38
    }
39
}
40