WordPress.org

Ready to get started?Download WordPress

Forums

Alfie WP Weather
[resolved] file_get_contents() alternative (cURL) (2 posts)

  1. CroModder
    Member
    Posted 5 months ago #

    Hi!
    First of all, praise for the plugin :)
    I tried it and it works perfect on localhost but when I put it online it doesn't work. I read FAQ, phpinfo() says that allow_url_fopen is turned on, and I tried playing with .htaccess and php.ini but apparently there is something messed up with permissions or there is some other problem with hosting.
    So I edited getfeed.php, replacing:
    $json = file_get_contents( $api, 0, null, null );
    with

    function file_get_contents_curl($url) {
    	$ch = curl_init();
    
    	curl_setopt($ch, CURLOPT_HEADER, 0);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
    	curl_setopt($ch, CURLOPT_URL, $url);
    
    	$data = curl_exec($ch);
    	curl_close($ch);
    
    	return $data;
    }
    $json = file_get_contents_curl($api);

    But the plugin still doesn't show up. Can you give me some instructions what else can I try?

    Thanks in advance!

    https://wordpress.org/plugins/alfie-wp-weather/

  2. CroModder
    Member
    Posted 5 months ago #

    Problem solved. Curl was disabled in hosting configuration. Now works fine.
    Marking as resolved.

Reply

You must log in to post.

About this Plugin

About this Topic