简单php post请求

        for ($i = 1000; $i < 11000; $i++) {
            $url = '***********';
            $client = new GuzzleHttpClient();
            $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 GuzzleHttpClient();

        $jar = new GuzzleHttpCookieCookieJar();
        $jar->clear();
        foreach ($_COOKIE as $key => $value) {
            $newCookie = GuzzleHttpCookieSetCookie::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;
    }

  

原文地址:https://www.cnblogs.com/psy-sdudio/p/8268260.html