7
嗨我想添加Facebook的連接到我的Android應用程序,我確實設法發佈在我的牆上的應用程序,但是當我下載Android的Facebook應用程序,並登錄它,但現在我不能張貼在我的牆上。我收到此錯誤:Android的Facebook ..如何獲得AccessToken
{"error":{"type":"OAuthException","message":"An active access token
must be used to query information about the current user."}}
CODE:
公共類FacebookLogin延伸活動{
private static final String APP_API_ID = "080808998-myappId";
Facebook facebook = new Facebook(APP_API_ID);
private AsyncFacebookRunner mAsyncRunner;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mAsyncRunner = new AsyncFacebookRunner(facebook);
SessionStore.restore(facebook, this);
SessionEvents.addAuthListener(new SampleAuthListener());
Log.i("Error", facebook.getAccessToken()+"tokenId");
facebook.dialog(FacebookLogin.this, "feed", new SampleDialogListener());
}
public void postOnWall(String msg) {
try {
Bundle bundle = new Bundle();
bundle.putString("message", msg);
bundle.putString("from", "fromMe");
bundle.putString("link","facebook.com");
bundle.putString("name","name of the link facebook");
bundle.putString("description","some description here");
//bundle.putString(Facebook.TOKEN, accessToken);
bundle.putString("picture", "http://url to image");
String response = facebook.request("me/feed",bundle,"POST");
Log.d("Error", "got response: " + response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} catch(Exception e) {
e.printStackTrace();
}
}}
令牌,我得到的是空。
謝謝,但我不明白在哪裏即時獲取accessToken ..如果我做facebook.authorize(這,新字符串[] {「publish_stream」},.. 我得到一個身份證在回報,但它不是一個令牌,我試過了你怎麼獲得sessionId或TokenId ...謝謝 – user606669 2011-05-10 10:56:45
問題通過在facebook.authorize的onComplete函數中調用getaccesstoken解決,並將其存儲在首選項中,以便每次檢查首選項並從那裏加載訪問令牌 – user606669 2011-05-10 13:40:23