Question: Give CURL Example with parameter in POST Method in Zend framework?
$config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'ssltransport' => 'tls', 'strict' => false, 'persistent' => true, ); $url = 'http://www.example.com'; $client = new Zend_Http_Client($url, $config); $postArray = array('name'=>'Georage','age'=>33); $client->setParameterPost($postArray); $response = $client->request('POST'); echo $response->getBody();
Question: How to set Header data in CURL with Zend Framework1?
$client->setHeaders(array( 'Host: www.example.com', 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0', 'Accept: text/javascript, application/javascript, */*', 'Accept-Language: en-gb,en;q=0.5', 'Accept-Encoding: gzip, deflate', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With: XMLHttpRequest', 'Referer: http://example.com' ));
Question: How to set Cookie data in CURL with Zend Framework1?
$client->setCookie('__utma', '174057141.1507422797.1392357517.1392698281.1392702703.3'); $client->setCookie('PHPSESSID', '0a12ket5d8d7otlo6uh66p658a5');
Question: How to set Content-Type in CURL with Zend Framework1?
$client->setHeaders('Content-Type', 'audio/flac');
Question: Give CURL Example with different option in Zend framework?
$config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'ssltransport' => 'tls', 'strict' => false, 'persistent' => true, ); $url = 'http://www.example.com'; $client = new Zend_Http_Client($url, $config); $postArray = array('name'=>'Georage','age'=>33); $client->setParameterPost($postArray); /** set Headers **/ $client->setHeaders(array( 'Host: www.example.com', 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0', 'Accept: text/javascript, application/javascript, */*', 'Accept-Language: en-gb,en;q=0.5', 'Accept-Encoding: gzip, deflate', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With: XMLHttpRequest', 'Referer: http://example.com' )); /** set cookie **/ $client->setCookie('__utma', '174057141.1507422797.1392357517.1392698281.1392702703.3'); $client->setCookie('PHPSESSID', '0a12ket5d8d7otlo6uh66p658a5'); $response = $client->request('POST'); $data= $response->getBody(); echo $data;
Question: How to Skip SSL Check in CURL using Zend Framework?
$url='www.example.com'; $config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array( CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE ), ); $client = new Zend_Http_Client($url, $config); $response = $client->request('GET');
Question: How to pass binary data of in CURL usig Zend Framework?
$file='http://example.com/test/GM-qE2zq-1078-5525_360p.flac'; $jsonData = ''; $config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,CURLOPT_SSL_VERIFYPEER =>FALSE), ); $url='https://stream.watsonplatform.net/speech-to-text/api/v1/recognize'; $client = new Zend_Http_Client($url, $config); //Set the Header value $client->setHeaders('Content-Type', 'audio/flac'); $client->setHeaders('Transfer-Encoding', 'chunked'); $client->setRawData(file_get_contents($file)); //Set post method $response = $client->request('POST'); $jsonData= ($response->getBody());