Jump to content

Using File_Get_Content With Get Methode


programAngel

Recommended Posts

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

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

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

it looks like the requested server is genrating a 500 error not problem with your script.

Link to comment
Share on other sites

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

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

@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

@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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...