simplexml_load_file: failed to open stream: HTTP request failed - php

I am trying to display rss feeds for this link. http://vuconnect.com/controls/cms_v2/components/rss/rss.aspx?sid=1643&gid=2&calcid=664&page_id=13
But it is showing this error
Warning:
simplexml_load_file(http://vuconnect.com/controls/cms_v2/components/rss/rss.aspx?sid=1643&gid=2&calcid=664&page_id=13):
failed to open stream: HTTP request failed! in
G:\wamp\www\scripts\rss_feeds\demo-1.php on line 48
Here is the code i am using.
$url = 'http://vuconnect.com/controls/cms_v2/components/rss/rss.aspx?sid=1643&gid=2&calcid=664&page_id=13';
$xml = simplexml_load_file($url);
echo '<pre>';
print_r($xml->channel);
die;
?>

needs allow_url_fopen to be On.
Check you php.ini and change it to On, if it is Off.
I hope this solves your problem

Related

PHP file_get_contents sometimes failed to open stream Http request failed

I have an ajax call that gets many, many pages of contents from a website, but it fails to open steams sometimes even though the same exact links that failed to open streams works just fine, when I ran them again. The problem is, then other links would failed to open stream. Anyone know why this is happening?
Warning: file_get_contents(http://www.merriam-webster.com/browse/dictionary/a/acoustically.htm): failed to open stream: HTTP request failed!

How can I fix Warning: file_get_contents() failed to open stream in PHP

I am trying to parse JSON data from an Ooyala URL but I'm having errors.
Sample Generated URL:
https://api.ooyala.com/v2/analytics/reports/account/performance/total/2015-01-01...2015-01-10?api_key=U3dms60g81_FPxszqQDbACnZsC_J.6so11&expires=1434366377&signature=NnE%2F6vsYOEJsrJ3yYEmO%2BXVXnr4d7ljDc8%2BvFNCkywo
Sample Response:
{"results":[{"id":"total","metrics":{"video":{"displays":90847,"uniq_displays":{"daily_uniqs":42819,"weekly_uniqs":32512,"monthly_uniqs":31838},"plays":27941,"uniq_plays":{"daily_uniqs":21075,"weekly_uniqs":17949,"monthly_uniqs":17679},"replays":1460,"uniq_replays":{"daily_uniqs":1101,"weekly_uniqs":1075,"monthly_uniqs":1075},"time_watched":4850762080,"playthrough_25":23086,"playthrough_50":21306,"playthrough_75":20013,"playthrough_100":16900,"player_loads":90688,"uniq_player_loads":{"daily_uniqs":42899,"weekly_uniqs":32565,"monthly_uniqs":31886},"video_bytes_downloaded":"This
metric has been
deprecated.","initial_plays":27597,"video_starts":27811,"uniq_video_starts":{"daily_uniqs":20992,"weekly_uniqs":17878,"monthly_uniqs":17609}}}}]}
Here's the error:
Warning: file_get_contents(<my URL here>): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\Ooyala\GetURL.php on line 84
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Ooyala\GetURL.php on line 84
Code I'm trying to run:
$content = file_get_contents($url);
$json = json_decode($content, true);
ini_set('max_execution_time', 360);
foreach($json['results']['metrics']['video'] as $item)
{
echo $item['playthrough_50'];
echo '<br>';
echo $item['video_starts'];
}
I have automatic configuration script in my internet options. Does it affect in using the file_get_contents() function?

use get parameters in DOMDocument::loadHTMLFile()

I want to load an url like this using DOMDocument::loadHTMLFile(): http://www.domain.com/dir/page?param1=235235&param2=2345, but it gives this error, even though the page exists:
Warning: DOMDocument::loadHTMLFile(http://www.domain.com/dir/page?param1=235235&param2=2345): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
How can I solve this?

PHP file get content error

In the following code i get error failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
$url = "https://graph.facebook.com/$orderId";
$url_with_token = $url . "?access_token=$token";
$result= json_decode(file_get_contents($url_with_token));
Please let me know where I am going wrong
Just add two lines in your php.ini file.
extension=php_openssl.dll
allow_url_include = On
its working for me.

load xml content from external xml file to php

I have written simple code to get content from xml file to php.
$xml = simplexml_load_file("http://localhost/xml_load/test_xml.xml");
print_r($xml);
First time It has run successfully but right now it is giving me warning and not executing properly.
Warning: simplexml_load_file(http://localhost/xml_load/test_xml.xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! <?xml version="1.0" encoding="ISO-8859-1"?> in C:\xampp\htdocs\XML_load\load_file.php on line 2
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://localhost/xml_load/test_xml.xml" in C:\xampp\htdocs\XML_load\load_file.php on line 2
No file found on your respective location. Now, either check if your file exist. However, do try to make your local path doesn't based over BASEURL. Add that path further like
$xml = simplexml_load_file("xml/files/myxml.xml"); // PATH TO YOUR FILE.
echo "<pre>"; print_r($xml); "</pre>";

Categories