Error getting long-lived access token: " . $helper->getMessage() . "
\n\n"; + exit; + } + } + + $_SESSION['fb_access_token'] = (string) $accessToken; + + // User is logged in with a long-lived access token. + // You can redirect them to a members-only page. + wp_redirect( admin_url( 'admin.php?page=fbr_plugin_opts&status=2' ) ); +} \ No newline at end of file diff --git a/includes/admin/init.php b/includes/admin/init.php new file mode 100644 index 0000000..4822fcf --- /dev/null +++ b/includes/admin/init.php @@ -0,0 +1,10 @@ + $fbr_app_id, + 'app_secret' => $fbr_app_secret, + 'default_graph_version' => 'v2.2', + 'default_access_token' => $_SESSION['fb_access_token'] + ]); + + try { + // Get the \Facebook\GraphNodes\GraphUser object for the current user. + // If you provided a 'default_access_token', the '{access-token}' is optional. + $response = $fb->get('/me/accounts'); + } catch(\Facebook\Exceptions\FacebookResponseException $e) { + // When Graph returns an error + echo 'Graph returned an error: ' . $e->getMessage(); + exit; + } catch(\Facebook\Exceptions\FacebookSDKException $e) { + // When validation fails or other local issues + echo 'Facebook SDK returned an error: ' . $e->getMessage(); + exit; + } + + $graphEdge = $response->getGraphEdge(); + } + ?> +Connectez-vous et autorisez Facebook Ratings à accéder à vos Pages.
+ +