Saturday, August 6, 2016

Why API/ file(url) request is not working/sending in cpanel / php

One of my web apps using API for SMS. I was using to send request as URL using file() function. Everything was working till i transfered my apps to another server. In new server it was not working even it was not sending the request.

I found from phpinfo() that allow_url_fopen was disable. To use file related php build-in function
like  fopen()copy()file_exists() , readfile()file() , file_get_contents() ,filesize() We need to make sure that  allow_url_fopen  is enabled.

If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.

allow_url_fopen, how to enable

This can be done via your php.ini file by adding the following line:
allow_url_fopen = On
The php.ini file is where you declare changes to your PHP settings. You can edit the existing php.ini, or create a new text file in any subdirectory and name it php.ini.

No comments:

Post a Comment

Total Pageviews