Can't access website via cURL from localhost but can from hosted server

I am writing a script that fetches XML data from wowarmory.com using PHP 5 and cURL:

$url = "http://www.wowarmory.com";
$userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12';

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$url);
$str  = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$str .= "Accept-Language: en-us,en;q=0.5\r\n";
$str .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$str .= "Keep-Alive: 300\r\n";
$str .= "Connection: keep-alive\r\n";
curl_setopt($ch, CURLOPT_HTTPHEADER, array($str));
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 3000);
$xml = curl_exec($ch);

      

When I run this from my hosted web server, I get an XML response as expected. But when running from my local web server, I get nothing.

I can get any other site via cURL from localhost (yahoo.com, even worldofwarcraft.com) but not wowarmory.com. So I know cURL works fine.

I am using the following PHP and cURL versions:

Hosted Server:

  • php 5.2.6
  • cURL libcurl / 7.16.1 OpenSSL / 0.9.7e zlib / 1.2.3

Localhost:

  • php 5.2.6
  • cURL libcurl / 7.16.0 OpenSSL / 0.9.8i zlib / 1.2.3

Any ideas?

EDIT: Localhost is running Windows XP SP3. I can access wowarmory.com through a web browser. Tracert starts timing at jump 13 (from my location, obviously):

13   458 ms   529 ms   549 ms  0.so-6-0-0.BR1.LAX15.ALTER.NET [152.63.116.21]
14   476 ms   510 ms   488 ms  192.205.34.29
15   257 ms   279 ms   261 ms  cr1.la2ca.ip.att.net [12.122.128.14]
16   242 ms   259 ms   249 ms  gar5.la2ca.ip.att.net [12.122.128.25]
17   252 ms     *     1691 ms  12.122.255.74
18     *     2361 ms   634 ms  mdf001c7613r0003-gig-10-1.lax1.attens.net [12.129.193.242]
19     *        *        *     Request timed out.

      

I'm not familiar with tcptraceroute unfortunately.

The binary version of curl for windows returns nothing for http://www.wowarmory.com/ but for http://www.yahoo.com/

I don't have wget.

EDIT 2: I can access my locally hosted site. This is just an answer from curl that I am not getting. I am running a fairly standard default XAMPP installation (apache 2 on windows xp). All this is wonderful.

+1


source to share


2 answers


Is it possible to access it from localhost through a web browser or even using command line utilities curl

or wget

?

What does he say tcptraceroute

?



If neither the web browser nor the command line utility works, but tcptraceroute

does (and does not show a transparent proxy somewhere in the path) and you are behind the DSL line, it is possible that your problem is the PMTU blackhole . If so, the workaround is MSS clamping .

+2


source


api is probably returning responses to some urls (say nextUrl or currentUrl). if your url is local or local system IP, how and where is the api response back ...? Coz api will respond back to nextUrl () or currentUrl (). So please use a permanent IP or domain name to work.



0


source







All Articles