我正试图在我的控制器中创建一个功能,将专辑发布到Facebook.每次访问该函数时,我都被重定向到REDIRECT_URI,就像$ userid = 0一样,即使我刚刚正确登录Facebook.这是因为登录后,它会重新启动该功能并创建一个新的Facebook会话,消灭我刚刚获得的用户?
感谢您的任何帮助,您可以提供.
function share($id){
if (!$id) { $this->Session->setFlash(__('Invalid id for Album', true));
$this->redirect(array('action'=>'index')); }
$photos = $this->Album->find('all', array('conditions' => array('Album.id' => $id)));
$facebook = new Facebook(array('appId'=>'valid aphid', 'secret'=>'valid secret'));
$facebook->setFileUploadSupport(true);
$userid = $facebook->getUser();
if($userid) {
try {
$user_profile = $facebook->api('/me'); // Gets User's information based on permissions the user has granted to your application.
}
catch(FacebookApiException $e){
error_log($e);
// Print results if you want to debug.
$userid = null;
}
} else {
$login_url = $facebook->getLoginUrl($params = …Run Code Online (Sandbox Code Playgroud)