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 pro开发者_如何学运维blem 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
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");
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.
精彩评论