Facebook oauth dialog redirect after login problem on mobile touch site

蓝咒 提交于 2019-12-08 11:01:57

问题


We redirect users to below URL on mobile phones for application authorisation:

https://m.facebook.com/dialog/oauth?client_id=XXXXXX&redirect_uri=http://www.server.com/callback.php&scope=offline_access,user_likes,publish_stream,publish_checkins,user_checkins&display=wap

If the user is logged in to Facebook on his/her phone, no problem, Facebook automatically redirects to oauth dialog page.

If user is not logged in, Facebook asks them to login first.
On wap site(A Nokia phone), it redirects to oauth dialog without any problem after login. But on touch site(An iPhone), it add hastags to URL, redirects user to his/her Facebook homepage.

Even display=wap parameter on URL doesn't help on this issue.

Any ideas on how to solve this problem?

Thank you


回答1:


Actually, here's a cleaner solution. (I hadn't seen the API for getLoginUrl at the time of my previous post. http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl)

require_once("facebook.php");

$config = array(
    "appId" => APP_ID,
    "secret" => APP_SECRET
);

$facebook = new Facebook($config);

$params = array(
    "scope" => "offline_access,user_likes,publish_stream,publish_checkins,user_checkins",
    "redirect_uri" => "http://www.server.com/callback.php",
    "display" => "touch"
);

$url = $facebook->getLoginUrl($params);

header("Location: $url");



回答2:


I experienced the same problem and had troubles isolating it since it worked in Chrome on the desktop but not while using the iPhone's Safari browser.

I did a urlencode around the redirect_url parameter and set display to touch. So to use your link above as an example, I'd try this:

https://m.facebook.com/dialog/oauth?client_id=XXXXXX&redirect_uri=http%3A%2F%2Fwww.server.com%2Fcallback.php&scope=offline_access,user_likes,publish_stream,publish_checkins,user_checkins&display=touch

I sincerely hope that works for you. It seemed to have brought me luck.



来源:https://stackoverflow.com/questions/7566970/facebook-oauth-dialog-redirect-after-login-problem-on-mobile-touch-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!