These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for php file_get_contents returning false ... on the new forum.
I am stuck with the issue.
Trying to retrieve rss from my url to a sub path, I am getting false. But the rss appears when retrieving it from the browser.
Here is my code. Could someone please advice me on what I should do ?
$this->feed = 'https://www.appsoma.com/blog/rss'; print_r($this->feed);echo PHP_EOL; // die('getting feed url'); $feed = file_get_contents($this->feed); var_dump($feed);
What is your php.ini configuration? In special the allow_url_fopen value.
Here is some code in PHP to get the content of an external URL, but using the CURL (recommended).
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = curl_exec($ch);
If you dont have curl installed on your server, here is some tips for CentOS:
yum install curl
yum install php-curl
yum install rh-php70-php-curl
The install of PHP depends on the version that you are using.