Facebook通过android登录 [英] Facebook login through android
问题描述
String response = facebookClient.request(me);
我收到此回复:
{error:{message:必须使用活动的访问令牌查询当前用户的
信息。,type:OAuthException}} p>
也许我有错误的哈希键(通过我阅读不错的线程如何正确)。我想知道这是否是确保密钥匹配的一种方式。
我基于我的代码 - Android / Java - 发布简单的文本到Facebook墙?,并添加一些小的更改。这是代码:
public class FacebookActivity extends Activity implements DialogListener
{
private Facebook Facebook客户端
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main); //我的布局xml
}
public void login(View查看)
{
facebookClient =新Facebook(我的APP ID);
facebookClient.authorize(this,this);
if(facebookClient.isSessionValid()== true)
Log.d(Valid:,yes);
else
Log.d(有效:,否);
}
}
那个授权方法是异步的。
你应该实现一个DialogListener的一个onComplete方法,并且使你需要的所有工作(如图API我要求)。
I write an Android application that integrates facebook, but failing in the login to facebook step. What I'm doing basically is to perform authorization and then ask if the session is valid. The answer is always negative. If I'm trying a simple request like:
String response = facebookClient.request("me");
I am getting this response:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException"}}
Maybe I have the wrong hash key (through I read pretty good threads how to get it right). I'd like to know if this is a way to insure key is matching.
I based my code on this - Android/Java -- Post simple text to Facebook wall?, and add some minor changes. This is the code:
public class FacebookActivity extends Activity implements DialogListener
{
private Facebook facebookClient;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);//my layout xml
}
public void login(View view)
{
facebookClient = new Facebook("my APP ID");
facebookClient.authorize(this, this);
if (facebookClient.isSessionValid() == true)
Log.d("Valid:", "yes");
else
Log.d("Valid:", "no");
}
}
Note that authorize method is asynchronous.
You should implement an onComplete method of DialogListener and make all the work you need (such as graph API me request) there.
这篇关于Facebook通过android登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!