天道酬勤,学无止境

zend-http-client

Zend_HTTP_Client 不会让我发布任何数据(Zend_HTTP_Client wont let me POST any data)

问题 我一直在整个 stackoverflow 和 Google 上搜索我的问题的解决方案。 我已经用 Zend Framework 创建了两个项目Project1和Project2我想在其中一个上实现 Web 服务。 这个想法是向Project1发送一个 JSON 字符串,并使用 POST 接收回一个 JSON,其中包含与该变量关联的所有详细信息。 现在我在Project2上创建了一个 TestController : public function indexAction(){ $uri = 'http://project1.com/WebService/data'; $config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => true), ); $client = new Zend_Http_Client($uri, $config); $request = $client->request('POST'); print_r($request->getBody()); exit(); } 上面的代码有效。 它从Project1控制器读取dataAction并为我提供任何回显的输出。 但是当我尝试这个时:

2021-12-20 12:48:42    分类:技术分享    php   web-services   zend-framework   zend-http-client

Zend_HTTP_Client wont let me POST any data

I have been searching all over stackoverflow and Google for a solution to my problem. I have created two projects with Zend Framework - Project1 and Project2 - and I want to implement web services on one of them. The idea is to send a JSON-string to Project1 and receive back a JSON with all the details associated with that variable using POST. Now I have created a TestController on Project2: public function indexAction(){ $uri = 'http://project1.com/WebService/data'; $config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => true), );

2021-12-12 18:58:26    分类:问答    php   web-services   zend-framework   zend-http-client

Zend_Http_Client POST '缺少必需的参数'(Zend_Http_Client POST 'missing required parameters')

问题 首先,我查看了这个问题并尝试了解决方案,但对我不起作用。 我在 PHP 7.0.22 服务器上使用 Zend 1.12。 我有一个函数应该将数据发布到 API 并接收发布的确认。 每当我在我的休息客户端中测试它时,在 firefox 中,我都会从 API 调用中得到以下响应: "{\"code\":400,\"text\":\"Missing required parameters.\"}" 。 当我添加标题时: Content-Type: application/x-www-form-urlencoded我得到预期的响应: '200, true' 。 但即使尝试在我的代码中显式设置此标头,它仍然总是返回400 。 控制器: $params = array(); $params[ 'name' ] = 'John'; $params[ 'email' ] = 'john@example.com'; $client = new Zend_Http_Client(); $client->setUri( 'path/to/my/api' ); $client->setParameterPost( $params ); $response = client->request( Zend_Http_Client::POST ); var_dump( $response )

2021-11-15 04:45:32    分类:技术分享    web-services   zend-framework   zend-http-client

Zend_Http_Client POST 'missing required parameters'

First of all, I looked at this question and tried the solution, did not work for me. I am working in Zend 1.12 on a PHP 7.0.22 server. I have a function that should post data to an API and receive a confirmation of the post. Whenever I test it in my rest client, in firefox, I get this response from the API call: "{\"code\":400,\"text\":\"Missing required parameters.\"}". When I add a header: Content-Type: application/x-www-form-urlencoded I get the expected respone: '200, true'. But even when trying to set this header in my code explicitly, it still always returns 400. Controller: $params =

2021-11-10 14:34:08    分类:问答    web-services   zend-framework   zend-http-client

Zend HTTP 客户端 URI 无效?(Zend HTTP Client Invalid URI?)

问题 我在 URL 上使用 Zend HTTP 时遇到问题: $client = new Zend_Http_Client('http://xxfire_killumiex.api.channel.livestream.com/2.0/info.json'); $feed = $client->request()->getBody(); 出于某种原因,这给了我一个错误...... Invalid URI supplied 这个特定的网址有什么问题吗? 回答1 这个特定的网址有什么问题吗? 下划线。 来自 RFC 1912 主机名标签中允许的字符仅为 ASCII 字母、数字和“-”字符。 编辑 多读几遍后,在这种情况下,似乎 Zend 可能是错误的。 请参阅(域名)子域中可以有下划线“_”吗? 根据 ZF-9671,你可能不走运,尽管我已经重新打开了这个问题。 同时我的建议; 像这样创建自己的 HTTP 客户端类 class My_Http_Client extends Zend_Http_Client { public function validateHost($host = null) { if ($host === null) { $host = $this->_host; } // If the host is empty, then it is considered

2021-10-25 06:37:06    分类:技术分享    zend-framework   zend-http-client

Zend HTTP Client Invalid URI?

I'm having trouble using Zend HTTP on a URL: $client = new Zend_Http_Client('http://xxfire_killumiex.api.channel.livestream.com/2.0/info.json'); $feed = $client->request()->getBody(); For some reason, this gives me an error... Invalid URI supplied Whats wrong this this specific url?

2021-10-24 16:50:19    分类:问答    zend-framework   zend-http-client

使用 Zend_Http_Client 时的内容类型错误(Content type-error when using Zend_Http_Client)

问题 我正在尝试使用 Zend_Http_Client 和 POST 将数据发送到 Google Analytic 的收集器。 我有一个数组$postParams ,其中包括我的跟踪 ID、cid 和命中类型,我通过setParameterPost()将此数组的值添加到我的客户端。 这是我的行动的相关部分: $client = new Zend_Http_Client('https://ssl.google-analytics.com/debug/collect'); foreach ($postParams as $postParam => $postValue) { $client->setParameterPost($postParam, $postValue); } $response = $client->request(); 调用此脚本时,出现以下错误: 无法自动处理内容类型“”。 请使用 Zend_Http_Client::setRawData 发送此类内容。 它在 Zend_Http_Client 的_prepareBody()方法中抛出。 当我添加echo($this->enctype); die(); echo($this->enctype); die(); 在那里,我收到NULL 。 我会添加$client->setEncType(); 到我的代码

2021-09-20 20:06:05    分类:技术分享    php   post   zend-framework   zend-http-client

Content type-error when using Zend_Http_Client

I'm trying to send data to Google Analytic's collector with Zend_Http_Client and POST. I have an array $postParams that's including my tracking-ID, cid and hit types and I add the values of this array to my client via setParameterPost(). Here's the relevant part of my Action: $client = new Zend_Http_Client('https://ssl.google-analytics.com/debug/collect'); foreach ($postParams as $postParam => $postValue) { $client->setParameterPost($postParam, $postValue); } $response = $client->request(); When calling this script I get the following error: Cannot handle content type '' automatically. Please

2021-07-28 11:12:07    分类:问答    php   post   zend-framework   zend-http-client

How to emulate POSTing multiple checkbox form fields myField[] with Zend_Http_Client?

I am using Zend_Http_Client to POST a set of data to my server running PHP. However, the server is expecting data in the form myField[], i.e. I have a set of check boxes and the user can check more than one. My current code is: foreach ($myValues as $value) { $this->client->setParameterPost('myField[]', $value); } However, it seems that Zend_Http_Client is simply overwriting myField[] with the new value each time it goes through the loop. How can I add multiple POST fields of the same name using Zend_Http_Client? UPDATE I have actually figured out a way to do this, by hacking the Zend_Http

2021-06-26 10:24:25    分类:问答    php   zend-framework   http   post   zend-http-client

authentication using Zend_Http_Client

I'm trying to use Zend_Http_Client to make a simple post request on a site that requires authentication. Everything seems to be correct but I'm still getting a You are not authorized to view this page error. Any ideas what the problem might be? I'm certain the username and password are correct $client = new \Zend_Http_Client('http://ncmcrm/sales_summary/activity_range.asp'); $client->setHeaders('WWW-Authenticate', 'Negotiate'); $client->setParameterPost(array( 'from_day' => 1, 'from_month' => 1, 'from_year' => 2012, 'to_day' => 31, 'to_month' => 1, 'to_year' => 2012, 'user_id' => '{BCDF3313

2021-06-23 11:07:54    分类:问答    php   zend-framework   zend-http-client