找到你要的答案

Q:HttpPost $params in Symfony2 LswApiCallerBundle

Q:HttpPost $params Symfony2 lswapicallerbundle

I am using this Bundle for my request. It works for all GETs, but I am stuck with the POST params, as it requires an object and I cannot find how such an object should look like.

I make this call:

$response = $this->get('api_caller')->call(new HttpPost("http://de.excample.com/webcams.php",REQUESTOBJECTGOESHERE);

and I would like to send parameters as "utf8 = yes".

Any hint appreciated!

我用这束我的要求。它适用于所有得到的,但我坚持后的参数,因为它需要一个对象,我找不到这样的对象应该是。

我打这个电话:

$response = $this->get('api_caller')->call(new HttpPost("http://de.excample.com/webcams.php",REQUESTOBJECTGOESHERE);

我想把参数作为“UTF8 =是的”。

任何提示赞赏!

answer1: 回答1:

It should be an associate array:

$requestObject = array('utf8' => 'yes');

From the source code of CurlCall it is doing the http_build_query on that object. The line 281 from that php source is as below:

\$this->requestData = http_build_query(\$this->requestObject);

它应该是一个关联数组:

$requestObject = array('utf8' => 'yes');

从curlcall源代码做http_build_query该对象。281号线从PHP源码如下:

\$this->requestData = http_build_query(\$this->requestObject);
php  symfony2  curl