SidewinderX Posted August 15, 2006 Share Posted August 15, 2006 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=616065on 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 https://forums.phpfreaks.com/topic/17691-php-connection-issue/ Share on other sites More sharing options...
Caesar Posted August 15, 2006 Share Posted August 15, 2006 Let me see if i understand, the only problems you had are with secure url's? (https)Make sure your host allows outgoing secure connections. Otherwise you will have to proxy out. :-) Link to comment https://forums.phpfreaks.com/topic/17691-php-connection-issue/#findComment-75417 Share on other sites More sharing options...
SidewinderX Posted August 16, 2006 Author Share Posted August 16, 2006 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 optionscurl_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 browsercurl_exec($ch);// close curl resource, and free up system resourcescurl_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 https://forums.phpfreaks.com/topic/17691-php-connection-issue/#findComment-75789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.