{"id":1538,"date":"2011-02-12T11:09:22","date_gmt":"2011-02-12T05:39:22","guid":{"rendered":"http:\/\/naveenbalani.com\/?p=1538"},"modified":"2017-03-24T18:06:29","modified_gmt":"2017-03-24T12:36:29","slug":"resolving-url-file-access-is-disabled-in-the-server-configuration","status":"publish","type":"post","link":"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/","title":{"rendered":"Resolving URL file access is disabled in the server configuration"},"content":{"rendered":"<p>I was trying out the simplexml_load_file function for parsing RSS feeds on my hosting server using the following code-<\/p>\n<p>$rss =\u00a0 simplexml_load_file(&#8216;http:\/\/naveenbalani.com\/index.php\/feed\/&#8217;);<\/p>\n<p>and got the following exception on my hosting server &#8211;<\/p>\n<p>&#8220;URL file access is disabled in the server configuration&#8221;<\/p>\n<p>After googling through the documentation, I noticed that the simple_xml_load uses furl_open function to get files remotely. This function, due to security issues was not supported on my hosting server (and probably most of the hosting providers.)<\/p>\n<p>The option was to use CURL library to parse remote urls , along with simple_xml function. Here is the modified code which should work on most of the hosting servers.<\/p>\n<pre>\r\n&lt;?php\r\n\r\nfunction load_file($url) {\r\n$ch = curl_init($url);\r\n#Return http response in string\r\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\r\n$xml = simplexml_load_string(curl_exec($ch));\r\nreturn $xml;\r\n}\r\n\r\n$feedurl = 'http:\/\/naveenbalani.com\/index.php\/feed\/';\r\n$rss = load_file($feedurl);\r\n\r\nforeach ($rss-&amp;gt;channel-&amp;gt;item as $item) {\r\necho \"&amp;lt;h2&amp;gt;\" . $item-&amp;gt;title . \"&amp;lt;\/h2&amp;gt;\";\r\necho \"&amp;lt;p&amp;gt;\" . $item-&amp;gt;description . \"&amp;lt;\/p&amp;gt;\";\r\n}\r\n\r\n&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was trying out the simplexml_load_file function for parsing RSS feeds on my hosting server using the following code- $rss =\u00a0 simplexml_load_file(&#8216;http:\/\/naveenbalani.com\/index.php\/feed\/&#8217;); and got the following exception on my hosting server &#8211; &#8220;URL file access is disabled in the server configuration&#8221; After googling through the documentation, I noticed that the simple_xml_load uses furl_open function to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2128,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,151],"tags":[152,154],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Resolving URL file access is disabled in the server configuration - Current and Future Technology Trends by Navveen Balani<\/title>\n<meta name=\"description\" content=\"Resolving URL file access is disabled in the server configuration -\" \/>\n<link rel=\"canonical\" href=\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Resolving URL file access is disabled in the server configuration - Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"og:description\" content=\"Resolving URL file access is disabled in the server configuration -\" \/>\n<meta property=\"og:url\" content=\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/\" \/>\n<meta property=\"og:site_name\" content=\"Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"article:published_time\" content=\"2011-02-12T05:39:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-24T12:36:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2016\/09\/bk6.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"450\" \/>\n\t<meta property=\"og:image:height\" content=\"374\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"1 minute\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/navveenbalani.dev\/#website\",\"url\":\"https:\/\/navveenbalani.dev\/\",\"name\":\"Current and Future Technology Trends by Navveen Balani\",\"description\":\"Current and Future Technology Trends by Navveen Balani\",\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/navveenbalani.dev\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2016\/09\/bk6.jpg\",\"width\":450,\"height\":374},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#webpage\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/\",\"name\":\"Resolving URL file access is disabled in the server configuration - Current and Future Technology Trends by Navveen Balani\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#primaryimage\"},\"datePublished\":\"2011-02-12T05:39:22+00:00\",\"dateModified\":\"2017-03-24T12:36:29+00:00\",\"description\":\"Resolving URL file access is disabled in the server configuration -\",\"breadcrumb\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/\",\"url\":\"https:\/\/navveenbalani.dev\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/\",\"name\":\"Resolving URL file access is disabled in the server configuration\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#webpage\"},\"author\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"headline\":\"Resolving URL file access is disabled in the server configuration\",\"datePublished\":\"2011-02-12T05:39:22+00:00\",\"dateModified\":\"2017-03-24T12:36:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"image\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/resolving-url-file-access-is-disabled-in-the-server-configuration\/#primaryimage\"},\"keywords\":\"php,simplexml\",\"articleSection\":\"Articles,PHP\",\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\",\"name\":\"Navveen\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/navveenbalani.dev\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/07\/navveen_balani.jpeg\",\"width\":200,\"height\":200,\"caption\":\"Navveen\"},\"logo\":{\"@id\":\"https:\/\/navveenbalani.dev\/#personlogo\"},\"sameAs\":[\"http:\/\/naveenbalani.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/1538"}],"collection":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/comments?post=1538"}],"version-history":[{"count":8,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/1538\/revisions"}],"predecessor-version":[{"id":1541,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/1538\/revisions\/1541"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media\/2128"}],"wp:attachment":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media?parent=1538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/categories?post=1538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/tags?post=1538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}