So recently I’ve begun work on a plugin for wordpress that integrates with facebook, I’ve never used Facebook’s SDK before, but after reading the documentation I felt relatively confident. But I’ve run into a problem at the oAuth level, my code does not seem to generate a loginUrl, when I look at the source on my plugin’s settings page, there is no link visible. The code in question is below:
oAuth.php
<?php
include_once('src/facebook.php');
$fbconfig = array(
'appId' => 'app1d',
'secret' => '53cr3t',
'cookie' => true
);
$facebook = new Facebook($fbconfig);
$loginUrl = $facebook->getLoginUrl(
array(
'scope' => 'offline_access, user_events',
'redirect_uri' => 'http://localhost/mad/wp-admin/options-general.php?page=facebook_event_options'
)
);
?>
And here’s the code on the menu page that isn’t working
This code is on another page, I’ve included oAuth.php on this page.
echo '<a href="' . $loginUrl . '"><img src="' . plugins_url('EventsList/images/connect.png') . '" class="fbConnect"></a>';
It’s probably something that’s so simple I haven’t noticed it, any help would greatly be appreciated 🙂
The issue is in the variables scope
Though you’d better wrapped all your retrieving link code into a function and call it, instead of using global variables