How to send data using POST in Zend_Rest_Client

The following code exists:

$client = new Zend_Rest_Client('http://test.com/rest');
$client->sendData('data');

if i send via GET( echo $client->get()) it works correctly

if through POST (echo $client->post()), I get the following message "No Method Specified."

How to send a message using Zend_Rest_Client?

+5
source share
2 answers

Perhaps this helps:

$base_url = 'http://www.example.com';
$endpoint = '/path/to/endpoint';
$data = array('param1' => 'value1', 'param2' => 'value2', 'param3' => 'value3');
$client = new Zend_Rest_Client($base_url);
$response = $client->restPost($endpoint, $data);
print_r($response);
+6
source

The following is the link for the class Zend_Rest_Client, as it indicates that we can use the public method restPost()to perform the post operation.

restPost ($path, $data=null)
Performs an HTTP POST request to $path. 

http://www.sourcecodebrowser.com/zend-framework/1.10.3/class_zend_ _client.html

0

All Articles