简单php post请求

        for ($i = 1000; $i < 11000; $i++) {
            $url = '***********';
            $client = new \GuzzleHttp\Client();
            $response = $client->request(
                'POST',
                $url,
                [
                    'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
                    'form_params' => [
                        'appid' => 'qdcacxpfuvdxsxpuaeuvqadwffrauqww',
                        'v' => '1.0.0.0',
                        'os' => 'android',
                        'terminal' => '2',
                        'channel' => '',
                        'udid' => '10X40VI9PlVlUDTBftGbd9oRF3lIDe7lf'.$i,
                        'timestamp' => '20161230161048',
                        'token' => '',
                        'sign' => '109d3ce559c86e6869fc097b81bd90b3',
                        'page' => '1',
                        'step' => '10',
                        'programType' => 'news',
                        'programId' => 'c6293dbb56fd4223838a3edd0a8815d8'
                    ]
                ]
            );


            $a = $response;
        }

  

 

   public function indexAction()
    {
        $url = '*****';
        $client = new \GuzzleHttp\Client();

        $jar = new \GuzzleHttp\Cookie\CookieJar();
        $jar->clear();
        foreach ($_COOKIE as $key => $value) {
            $newCookie = \GuzzleHttp\Cookie\SetCookie::fromString() ;  //::fromString($key'Name=' . $key . ';' . 'Value=' . $value . ';' . 'Domain=qa-api.dowedo.com.cn');
            $newCookie->setName($key);
            $newCookie->setValue($value);
            $newCookie->setDomain('qa-api.dowedo.com.cn');
            $jar->setCookie($newCookie);
        }

        $defaultOptions = ['cookies' => $jar];
        /**
         * Now loop through the cookies adding them to the jar
         */


        $response = $client->request(
            'GET',
            $url, $defaultOptions
        );

        $a = (string)$response->getBody();
        return $response;
    }

  

posted @ 2018-01-11 14:33  CarterLee  阅读(362)  评论(0编辑  收藏  举报