Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用HTTP发布请求_Http_Post_Guzzle - Fatal编程技术网

使用HTTP发布请求

使用HTTP发布请求,http,post,guzzle,Http,Post,Guzzle,我试图发出一个post请求,如以下示例所示: $response = $guzzle->post('http://www.website.com/abc.asp?2014:62/9/931/99999', [ 'body' => [ 'f' => 'json' ] ]); $request = $guzzle->createRequest( 'POST',

我试图发出一个post请求,如以下示例所示:

$response = $guzzle->post('http://www.website.com/abc.asp?2014:62/9/931/99999', [
                 'body' => [ 'f' => 'json' ]
            ]);
$request = $guzzle->createRequest(
                  'POST', 
                  'http://www.website.com/abc.asp?2014:62/9/931/99999', [
                     'body' => [ 'f' => 'json' ]
               ]);

$request->getQuery()->setEncodingType(false); // magic line :-)

$response = $guzzle->send($request);

但是当我运行该代码时,我得到了一个505错误,因为url是在

之后进行编码的,您应该禁用查询字符串编码。试试这个例子:

$response = $guzzle->post('http://www.website.com/abc.asp?2014:62/9/931/99999', [
                 'body' => [ 'f' => 'json' ]
            ]);
$request = $guzzle->createRequest(
                  'POST', 
                  'http://www.website.com/abc.asp?2014:62/9/931/99999', [
                     'body' => [ 'f' => 'json' ]
               ]);

$request->getQuery()->setEncodingType(false); // magic line :-)

$response = $guzzle->send($request);