伙计们,我正在尝试访问用户的个人信息。我正在使用 Facebook-sdk Laravel Bundle。事情是...
<?php
class App_Controller extends Base_Controller {
public $restful = true;
public function get_check()
{
// Chequeo que el FbId haya puesto Like en la pagina
$facebook = IoC::resolve('facebook-sdk');
$accessToken = $facebook->getAccessToken();
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}else{
$params = array(
'scope' => 'read_stream, friends_likes',
'redirect_uri' => 'http://someurl.com' // I've removed the actual url
);
$login_url = $facebook->getLoginUrl($params);
//return Response::make( '', 302 )->header( 'Location', $login_url );
}
echo $user;
}
public function get_game()
{
// Imprimo la pantalla del juego
return View::make('game');
}
/*public function get_logout(){
$facebook = IoC::resolve('facebook-sdk');
$user = $facebook->getUser();
$params = array(
'scope' => 'read_stream, friends_likes',
'redirect_uri' => 'http://www.conamor.org/apps/aventuracenter/pacman/public/game/'
);
if($user){
$url = $facebook->getLogoutUrl();
}else{
$url = $facebook->getLoginUrl();
}
header("Location: ".$url);
}*/
}
所以,当我回显 $user 时,我只得到 0 作为它的值,而不是一个对象。任何想法?
谢谢!