Bonjour,
j'ai fait une page avec un facebook connect qui mène à celle-ci :
<?
/*
For this to work you will have to download the Facebook PHP SDK
https://github.com/facebook/php-sdk/
*/
require('facebook.php');
/*
Set these variables to application's ones
*/
$app_id = '294504120659431';
$app_secret = 'deec368071d842c86a8399226fbd0b14';
// init fb object
$facebook = new Facebook(array(
'appId' => 'APPid que j'ai entré !',
'secret' => 'APPsecret que j'ai entré !',
'cookie' => false
));
// get a session for user
$session = $facebook->getSession();
$me = null;
// if have session get user data
if ($session)
{
try
{
$uid = $facebook->getUser();
$me = $facebook->api('/me');
}
catch(FacebookApiException $e)
{
error_log($e);
}
}
// if we have user data show logout button, else show login button with extended permission to get his email addy
$data = '';
if ($me)
{
// store user data here!!!
print_r($me);
$logoutUrl = $facebook->getLogoutUrl();
$data = '<a href="'.$logoutUrl.'"><img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif"></a>';
}
else
{
$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'email,read_stream'));
$data = '<a href="'.$loginUrl.'"><img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif"></a>';
}
// for javascript side use the same session
$fb_session = json_encode($session);
if(isset($me)){
$fql = "select uid,name,pic_big from user where uid=$uid";
$param = array(
'method' => 'fql-query',
'query' => $fql,
'callback' => ''
);
$fb = $facebook->api($param);
print_r($fb);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login with Facebook!</title>
</head>
<body>
<p>Hello!</p>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
//<![CDATA[
FB.init({
appId: '<?='294504120659431';?>',
cookie: true,
status: true,
xfbml: true,
session: <?=$fb_session;?>
});
FB.Event.subscribe('auth.login', function(){
window.location.reload();
});
//]]>
</script>
</body>
</html>
mais quand je l'execute avec WAMP ca ne me marque pas les infos utilisateur... :(
Help please :/
Merci d'avance !
Chris.