Jump to content

php connection issue


SidewinderX

Recommended Posts

I built a program on my local server and it worked perfectly, I then uploaded it to my remote webserver and it does not work. I debuged it and found out it is a problem with the second line... the file_get_contents() function; it dosnt work for a particular URL. I tested this and it worked fine:
[code]<?php
$url = "http://www.google.com";
$content = file_get_contents($url);
echo $content;
?>[/code] but when i try this code with the different url it dosnt work: [code]<?php
$url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065";
$content = file_get_contents($url);
echo $content;
?>[/code] When i first started using this code on my local server I hade a problem with this also, and the issue was that https wasnt a registered stream, but i installed OpenSSL and it worked fine on my local server, however even on my remote server https is a registered stream and OpenSSL is installed. I then thought that novaworld.com may bock my from using file_get_conents (possable?). So rather than using file_get_contents I used a curl script to do the same thing. [code]<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?> [/code] Much to my dismay that didnt work either. Finally i did a #curl https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065
on my linux box i get: [quote]<html><head><title>Object moved</title></head><body><ht>Object moved to <a href='/Players/Search.aspx'>here</a>.</h2></body></html>[/quote]

Could this be a cookie issue even though i dont go through 2 pages? Someone also mentioned they may filter the user-agent in requests. I have no idea what they are or how to combat that, but surley there is a way to connect to that website.

I welcome all help.
Thank you for taking your time to read this.
Sidewinder
Link to comment
Share on other sites

ok, well at first I wasnt sure if the problem persisted with all https connections, but I tested a few others and it is indded a problem with https. I emailed my host and after a few emails they replyed:
[quote]Hi,

Please check your script now.  We have opened outgoing connections to 443 on the server.
Thank you.[/quote]

Now, other https connections work, but not the one I want. Here is my current code:
[code]<?php
// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065");
curl_setopt($ch, CURLOPT_USERAGENT,  "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);
// close curl resource, and free up system resources
curl_close($ch);
?>[/code]

Also note, if i connect using a proxy it DOES work, but i would rather not use a proxy.

Any other ideas?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.