franklinfs Posted November 7, 2013 Share Posted November 7, 2013 (edited) How can i execute an url using curl from my module in prestashop 1.5.4.1 The sample url is https://abcd.com/shop/xyz?name=aaaaa&id=1 Edited November 7, 2013 by franklinfs (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 7, 2013 Share Posted November 7, 2013 try to use this function: function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_SSL_VERIFYPEER => false // Disabled SSL Cert checks ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } call it with code: $contents=$this->get_web_page('https://abcd.com/shop/xyz?name=aaaaa&id=1'); 2 Link to comment Share on other sites More sharing options...
franklinfs Posted November 8, 2013 Author Share Posted November 8, 2013 (edited) Hi Vekia, Thanks for your reply. Actually your code may gives correct output. But i didnt get the proper output. I think because of some resaons... If i copy this link and paste to browser, it will goes to the 3rd party server login page and it ask the user name and password. when i enter the username and password,the url is executes successfully; So i think we need to pass the username and password through curl. Edited November 8, 2013 by franklinfs (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts