Note that there are some explanatory texts on larger screens.

plurals
  1. POPOST request with Zend_Http_Client or CURL
    text
    copied!<p>I was trying to retrieve data from remote server but it wasn't working &amp; sending empty data. Here is the code that I tried:</p> <pre><code>define('WWW_PATH', dirname(__FILE__) . '/../..'); set_include_path(implode(PATH_SEPARATOR, array(realpath(WWW_PATH . '/library'), get_include_path()))); require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader-&gt;registerNamespace('Zend_'); $data = array( 'sr' =&gt; '3', 'et' =&gt; '3', 'exam' =&gt; 'ssc', 'year' =&gt; '2007', 'board' =&gt; 'dhaka', 'roll' =&gt; '494548' ); $client = new Zend_Http_Client(); $client-&gt;setUri('http://www.educationboardresults.gov.bd/regular/result.php'); $client-&gt;setParameterPost($data); $response = $client-&gt;request('POST'); $result = array('data'=&gt;$response-&gt;getBody()); echo json_encode($result); </code></pre> <p>When I tried to echo the result it's redirecting to index.php page. Any suggestion how to get data. I tried with curl but same problem here also :(</p> <pre><code>$post_data['sr'] = '3'; $post_data['et'] = '3'; $post_data['exam'] = 'ssc'; $post_data['year'] = '2007'; $post_data['board'] = 'dhaka'; $post_data['roll'] = '494548'; foreach ( $post_data as $key =&gt; $value) { $post_items[] = $key . '=' . $value; } $post_string = implode ('&amp;', $post_items); $curl_connection = curl_init('http://www.educationboardresults.gov.bd/regular/result.php'); curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl_connection, CURLOPT_POST, 1); curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); $result = curl_exec($curl_connection); curl_close($curl_connection); //var_dump($result); $data= array('data'=&gt;$result); echo json_encode($data); </code></pre> <p>and</p> <pre><code>$ch = curl_init(); $curlConfig = array( CURLOPT_URL =&gt; "http://www.educationboardresults.gov.bd/regular/result.php", CURLOPT_POST =&gt; true, CURLOPT_RETURNTRANSFER =&gt; true, CURLOPT_POSTFIELDS =&gt; array( 'sr' =&gt; '3', 'et' =&gt; '3', 'exam' =&gt; 'ssc', 'year' =&gt; '2007', 'board' =&gt; 'dhaka', 'roll' =&gt; '494548', ), ); curl_setopt_array($ch, $curlConfig); $result = curl_exec($ch); curl_close($ch); $data= array('data'=&gt;$result); echo json_encode($data); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload