我正在使用Symfony2,我尝试在我的一个测试(PHPUnit)中使用Guzzle来设置我的请求中的一些值。
我想在我的请求中添加以下内容:
$string = '{
"postcode":"XXX-XXX",
"source_channel":"BU",
"flow":"ENQUIRY",
"email_address":"test@test",
"first_name":"Bob",
"surname":"White",
"User-Agent":"Mozilla",
}';我的迷惑代码:
$client = new \Guzzle\Http\Client();
$post = $client->post('http://127.0.0.1/api/save/details', array(), $string);
$data = $post->send();错误:
Guzzle\Http\Exception\ClientErrorResponseException: Client error response
[status code] 404
[reason phrase] Not Found
[url] http://127.0.0.1/api/save/details我真的是个新手,但我想要做的事情似乎很简单。我从错误消息中假设可能是错误的,但是URL有问题,事实上我知道它是好的……
你知道这里可能出了什么问题吗?
发布于 2015-07-03 18:57:55
在我看来,你的网址的域名部分有一个拼写错误。试着改变
'http://127.0.0.1:/api/save/details'至
'http://127.0.0.1/api/save/details'https://stackoverflow.com/questions/31204695
复制相似问题