WordPress.org

Ready to get started?Download WordPress

Forums

Facebook Comments to WordPress
allow_url_fopen not allow for many host - please change fil (1 post)

  1. Nadiamode
    Member
    Posted 3 years ago #

    hi i dont want to enable url_fopen function in my ini file because security concern
    and many hosts out there also not allow this function too so i think many people wont be able use your plugin your plugin wont work with thier blog but they dont know what happen

    when general user see your plugin doesn't work they will uninstall and find new plugin so maybe you dont know what happen because nobody tell you - but i try and i know and i come to tell you

    file_get_contents require allow_url_fopen = on but many hosts off it

    please move from file_get_contents to curl, it easy - you can read here for example

    http://www.kevinkorb.com/post/3
    http://phpcode.mypapit.net/how-to-solve-file_get_contents-and-file-php-errors/45/

    example
    change from

    private function fetchCommentsFor($permalink, $locale) {
            // DEBUG:
            // $permalink = "http://gotvarstvo.georgievi.net/a/cvetnica";
            $request_url = "http://graph.facebook.com/comments/?ids=" .
                    urlencode($permalink);
            if ($locale != '') $request_url .= '&locale=' . $locale;
    
            $requests = @file_get_contents($request_url);
            if ($requests === FALSE) return FALSE;
    
            return @current(json_decode($requests, TRUE));
        }

    to

    private function fetchCommentsFor($permalink, $locale) {
    				  $permalink = get_permalink();
    
    				  $ch = curl_init();
    				  $timeout = 10; // set to zero for no timeout
    				  curl_setopt ($ch, CURLOPT_URL, "https://graph.facebook.com/comments/?ids=" .
    										  urlencode($permalink));
    				  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    				  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    				  $requests = curl_exec($ch);
    				  curl_close($ch);
    
            if ($requests === FALSE) return FALSE;
    
            return @current(json_decode($requests, TRUE));
        }

    http://wordpress.org/extend/plugins/facebook-import-comments/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic