WordPress.org

Ready to get started?Download WordPress

Forums

WP-AutoSocial
[resolved] Token Problems (4 posts)

  1. L D
    Member
    Posted 2 years ago #

    Hello,

    When I click "Get Token!" the page refreshes and says that "Facebook connected successfully" but it also has "Facebook: Configuration missing!"

    There is no OAuth popup when I clicked "Get Token!" Do you know how I can fix this?

    Thanks!

    http://wordpress.org/extend/plugins/wp-autosocial/

  2. L D
    Member
    Posted 2 years ago #

    Something is wrong with your CURL function. This is what I tried and it works:

    wp-autosocial.php; find "autosocial_graph" for the reference point:

    function curl_get_contents ($url) {
    	$curl = curl_init();
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($curl, CURLOPT_URL, $url);
    	$html = curl_exec($curl);
    	curl_close($curl);
    	return $html;
    }
    
    function autosocial_graph($url, $fields = array()) {
       // function to get facebook graph api results
       //$output = file_get_contents($url);
       //$output = makeRequest($url, $fields);
       $output = curl_get_contents($url);
       return $output;
    }

    But if I use makeRequest, then the call fails:

    function autosocial_graph($url, $fields = array()) {
       // function to get facebook graph api results
       //$output = file_get_contents($url);
       $output = makeRequest($url, $fields);
       //$output = curl_get_contents($url);
       return $output;
    }

    You're also still using file_get_contents for the Bit.ly function:

    function autosocial_bitly($post_ID = 0, $link = '') {
    
    ... some code here ...
    
       $bitly = json_decode(@file_get_contents('http://api.bit.ly/shorten?version=2.0.1&login='.$login.'&apiKey='.$api_key.'&longUrl='.$bl_link.'&history=1'));

    I can't figure out what's wrong and I'd rather not use my crude hack. Could you take a look at it and update? Thanks!

  3. L D
    Member
    Posted 2 years ago #

    Oh, nevermind. makeRequest() is a protected method of the Facebook class.

    I'm not very good with classes so if anyone is looking for a quick fix, here it is:

    Open wp-autosocial.php. Find add_action('init', 'autosocial_init');. Right after that line, insert the following:

    function curl_get_contents ($url) {
    	$curl = curl_init();
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($curl, CURLOPT_URL, $url);
    	$html = curl_exec($curl);
    	curl_close($curl);
    	return $html;
    }

    Now find all instances of file_get_contents. Replace file_get_contents with curl_get_contents. There should be two that you'll change.

    Once you've done that, save, and you're good to go.

  4. Pau Capó
    Member
    Plugin Author

    Posted 2 years ago #

    This was something I had to do! I will improve it anyway with:

    function autosocial_graph($url, $fields = array()) {
       // function to get facebook graph api results
       if (function_exists('curl_version')) {
          $curl = curl_init();
          curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($curl, CURLOPT_URL, $url);
          $output = curl_exec($curl);
          curl_close($curl);
       } else
          $output = @file_get_contents($url);
       return $output;
    }

    The CURL extensions is not active on all hostings, so I need to use the best in any case.
    I'll update the plugin now ;)

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic