0

i want to use CURL with addon ip which is added on my server So i am using below script for simple CURL pass.

<?php

function get_html($url,$ip) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_INTERFACE, $ip);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}



$ip="173.214.xxx.198";
$l = get_html("http://www.checkip.com/",$ip);


echo $l;
?>

This script running fine on other server . Please give me solution of this problem

  • what are you providing as interface IP? local IP of your system or the public IP of your network??? and please tell us your network structure (general info) through which the curl request must pass. and please see https://curl.haxx.se/libcurl/c/CURLOPT_INTERFACE.html and also see http://stackoverflow.com/questions/24585025/what-is-the-curl-option-curlopt-interface-and-when-to-use-it – BetaDev Mar 24 '17 at 15:18
  • Providing public ip which is added on server or PHP Version 5.6.30 ,Apache/2.4.6 (CentOS) – Narendra Dagar Mar 25 '17 at 10:42

1 Answers1

0

If it works fine on another server then there's nothing wrong in this script. Do you have curl installed on the server that's failing?

Ollie in PGH
  • 2,559
  • 2
  • 16
  • 19