programAngel Posted December 4, 2011 Share Posted December 4, 2011 Hi I am using the file_get_contents function: file_get_contents('http://ticketnet.co.il/ticketNet/jsp/Cinema/RSS_he.jsp?siteTypeId=5&customerId=Berale&pHandler=254&externalSiteId=Berale&affiliateMemberID=1&affiliateName=TicketNet&affiliatePublicPassword=&userLang=0'); The problem is that because it contain "?siteTypeId=5&customerId=Berale&pHandler=254&externalSiteId=Berale&affiliateMemberID=1&affiliateName=TicketNet&affiliatePublicPassword=&userLang=0" it doesn't work good. How can I pass variables via GET when I use file_get_contents. Link to comment Share on other sites More sharing options...
thescientist Posted December 4, 2011 Share Posted December 4, 2011 I would make a cURL/HTTP request to the url Link to comment Share on other sites More sharing options...
programAngel Posted December 4, 2011 Author Share Posted December 4, 2011 I would make a cURL/HTTP request to the urlwhat exactly do you mean? And how would you do that? Link to comment Share on other sites More sharing options...
birbal Posted December 4, 2011 Share Posted December 4, 2011 what do you mean it does not work good?...it is returning something or it is failing ? what is happening actualy? Link to comment Share on other sites More sharing options...
programAngel Posted December 4, 2011 Author Share Posted December 4, 2011 what do you mean it does not work good?...it is returning something or it is failing ? what is happening actualy?I get the following error:[b]Warning[/b]: file_get_contents(http://ticketnet.co.il/ticketNet/jsp/Cinema/RSS_he.jsp?siteTypeId=5&customerId=Berale&pHandler=254&externalSiteId=Berale&affiliateMemberID=1&affiliateName=TicketNet&affiliatePublicPassword=&userLang=0) [[url="http://www.talkimage.co.il/netevent/function.file-get-contents"]function.file-get-contents[/url]]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in [b]/hermes/web01c/b316/pow.talkimagecoil/htdocs/netevent/RSS.php[/b] on line [b]63[/b] Link to comment Share on other sites More sharing options...
birbal Posted December 4, 2011 Share Posted December 4, 2011 it looks like the requested server is genrating a 500 error not problem with your script. Link to comment Share on other sites More sharing options...
thescientist Posted December 4, 2011 Share Posted December 4, 2011 I think it's because you are trying to read the file's contents, not executing the code as script with the given params. file_get_contents just reads the file data.http://php.net/manual/en/function.file-get-contents.php Link to comment Share on other sites More sharing options...
Ingolme Posted December 4, 2011 Share Posted December 4, 2011 I think it's because you are trying to read the file's contents, not executing the code as script with the given params. file_get_contents just reads the file data.http://php.net/manua...et-contents.php If the file is on another server, the server executes the script first. Link to comment Share on other sites More sharing options...
birbal Posted December 4, 2011 Share Posted December 4, 2011 @thescintist i belive it should work with it. as the file is requested via url HTTP protocol the file will be executed. is not it? Link to comment Share on other sites More sharing options...
thescientist Posted December 4, 2011 Share Posted December 4, 2011 @Ingiome/birbal - good to know. well trying the URL on it's own in the browser seems ok... http://ticketnet.co.il/ticketNet/jsp/Cinema/RSS_he.jsp?siteTypeId=5&customerId=Berale&pHandler=254&externalSiteId=Berale&affiliateMemberID=1&affiliateName=TicketNet&affiliatePublicPassword=&userLang=0 Link to comment Share on other sites More sharing options...
JamesB Posted December 4, 2011 Share Posted December 4, 2011 it appears that particular server requires a user-agent request header to get a 200 response. file_get_contents() on that URL just sends this for me: GET /ticketNet/jsp/Cinema/RSS_he.jsp?siteTypeId=5&customerId=Berale&pHandler=254&externalSiteId=Berale&affiliateMemberID=1&affiliateName=TicketNet&affiliatePublicPassword=&userLang=0 HTTP/1.0Host: ticketnet.co.il edit: seems to work: <?php$context = stream_context_create(array( 'http' => array( 'header' => 'User-Agent: PHP' )));$url = 'http://ticketnet.co.il/ticketNet/jsp/Cinema/RSS_he.jsp?siteTypeId=5&customerId=Berale&pHandler=254&externalSiteId=Berale&affiliateMemberID=1&affiliateName=TicketNet&affiliatePublicPassword=&userLang=0';echo file_get_contents($url, false, $context); Link to comment Share on other sites More sharing options...
programAngel Posted December 6, 2011 Author Share Posted December 6, 2011 JamesBThank you.You solved my problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.