Thread Starter
Anonymous User 5746546
(@anonymized-5746546)
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!
Thread Starter
Anonymous User 5746546
(@anonymized-5746546)
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.
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!