-1

i am using curl in my program.
and my code is :

$tref = $_GET['tref'];

$url = "https://paypaad.bankpasargad.com/PaymentTrace";
$curl_session = curl_init($url); // Initiate CURL session -> notice: CURL should be enabled.
curl_setopt($curl_session, CURLOPT_POST, 1);    // Set post method on.
//curl_setopt($curl_session, CURLOPT_FOLLOWLOCATION, 1); // Follow where ever it goes
curl_setopt($curl_session, CURLOPT_HEADER, 0); //Don't return http headers
//curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); // Return the content of the call
$post_data = "tref=".$tref;
curl_setopt($curl_session, CURLOPT_POSTFIELDS, $post_data);

// Get returning data
$output = curl_exec($curl_session);
print_r($output);
print_r($post_data);

but when i use this code in my hosting , $output not set and when use another server this code correctly.
how i doing in my server.

tshepang
  • 12,111
  • 21
  • 91
  • 136
aya
  • 1,597
  • 4
  • 29
  • 59

2 Answers2

2

hey found this code :

$data = curl_exec($curl_handle);
if ($data === FALSE) {
   die(curl_error($curl_handle));
} else {
   $html_str .= $data;
}

and when i use this code , i face this this error :

SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

then i search this error and face this link http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

and i add this code

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

before

curl_exec():

aya
  • 1,597
  • 4
  • 29
  • 59
  • 1
    You can select your own answer. Do this please, so the community knows it's solved, and people with the same problem see it's solved. – 11684 Jun 14 '12 at 12:18
0

Make sure your server curl is enable..

Change ;extension=php_curl.dll To

extension=php_curl.dll

in php.ini you also check this Call to undefined function curl_init().?

Community
  • 1
  • 1
Pramod Kumar Sharma
  • 7,851
  • 5
  • 28
  • 53