2011-01-18 8 views
5

में पोस्ट का उपयोग कर के माध्यम से डेटा भेजने के लिए अगले कोड है:कैसे Zend_Rest_Client

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

अगर मैं के माध्यम से GET (echo $client->get()) भेजने यह काम करता है सही

अगर के माध्यम से POST(echo $client->post()) मैं हो रही है अगला संदेश "कोई विधि निर्दिष्ट नहीं है।"

Zend_Rest_Client का उपयोग करके पोस्ट कैसे भेजें?

उत्तर

6

हो सकता है कि इस मदद करता है:

$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); 
0

नीचे Zend_Rest_Client कक्षा के लिए लिंक है, क्योंकि यह दर्शाता है कि हमने पोस्ट कार्रवाई करने के लिए सार्वजनिक विधि restPost() उपयोग कर सकते हैं।

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

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