Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force IPv4 in cURL in PHP application

Is there any way to force cURL to use IPv4? I'm looking for like a global setting, like php.ini setting or something like that.

like image 642
smilebomb Avatar asked Sep 03 '14 13:09

smilebomb


1 Answers

Please try this code, with curl_setopt
This will force the IPV4 resolving.

if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
   curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}

the defined insure that the global constants available on your PHP version.

like image 174
mr.baby123 Avatar answered Oct 21 '22 17:10

mr.baby123