Support » Plugin: Woocommerce FB Comment & Share » Warning: file_get_contents() alternative with curl

  • Hi,

    we like ur plugin, but since some server security configurations, we have troubles, because

    “Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0”

    Located in
    “File: /wp-content/plugins/fb-comment-share-for-woocommerce/frontend/fbc-class-frontend.php”

    Please update to something like below, to look for _getter and prefer if available, the curl _getter:

    function fbc_comment_count() {
    global $post, $product;

    $url = get_permalink($post->ID);
    // Produce error:
    // $filecontent = file_get_contents(‘https://graph.facebook.com/?ids=’ . $url);
    // Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /kunden/506462_20537/webseiten/meine-wilde-wiese.de/wordpress/wp-content/plugins/fb-comment-share-for-woocommerce/frontend/fbc-class-frontend.php on line 142
    // Warning: file_get_contents(https://graph.facebook.com/?ids=https:///): failed to open stream: no suitable wrapper could be found in //wp-content/plugins/fb-comment-share-for-woocommerce/frontend/fbc-class-frontend.php on line 142
    // Notice: Trying to get property ‘/’ of non-object in //wp-content/plugins/fb-comment-share-for-woocommerce/frontend/fbc-class-frontend.php on line 145
    // Notice: Trying to get property ‘comments’ of non-object in //wp-content/plugins/fb-comment-share-for-woocommerce/frontend/fbc-class-frontend.php on line 145
    // $filecontent = file_get_contents(‘https://graph.facebook.com/?ids=’ . $url);
    // Itdah
    // allow_url_fopen active?, file_get_contents wrapper disabled, alternative curl
    if(function_exists(‘curl_init’)) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, ‘https://graph.facebook.com/?ids=’ . $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $filecontent = curl_exec($ch);
    curl_close($ch);
    } elseif(ini_get(‘allow_url_fopen’)) {
    $filecontent = file_get_contents(‘https://graph.facebook.com/?ids=’ . $url);
    }
    // Itdah comments prop missing
    $count = 0;
    $json = json_decode($filecontent);
    if(isset($json->$url->comments)) {
    $count = $json->$url->comments; // Error, when no comment entered
    }
    // END itdah

    $wpCount = get_comments_number();
    $realCount = $count + $wpCount;
    if ($realCount == 0 || !isset($realCount)) {
    $realCount = 0;
    }
    return $realCount;
    }

    Also nice to have in plugin main file, woocommerce version hints, to compare in wordpress plugins page for compatibility:

    Best regards,
    Alex

  • You must be logged in to reply to this topic.