2013-07-09 44 views
0

我希望能夠從我的Android應用程序分享文章,但我無法實現這一目標。我已將facebook sdk 3.0添加到我的應用程序中。我可以得到一個userName,userFirstName,userLastName等,但我無法發送提要。 下面是我使用的代碼:ME /訂閱的Facebook的Android SDK 3.0

Bundle postParams = new Bundle(); 
postParams.putString("name", "Facebook SDK for Android"); 
postParams.putString("caption", "Build great social apps and get more installs."); 
postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps."); 
postParams.putString("link", "https://developers.facebook.com/android"); 
postParams.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png"); 

Request.Callback callback= new Request.Callback() { 
    public void onCompleted(Response response) { 
         Log.e("Sonuc", "Geldi"); 
    } 
}; 

Request request = new Request(session, "me/feed", postParams, HttpMethod.POST, callback); 
RequestAsyncTask task = new RequestAsyncTask(request); 
task.execute(); 

這個片段是從 https://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/

當我執行該代碼就會記錄在它成功完成。我的意思是Request.Callback的方法的onComplete正常工作.. 閒來無事被記錄爲錯誤。我不明白爲什麼它不起作用?這與發佈權限有關嗎?

什麼是在這個片段中的問題?

回答

0

也許你忘記讓「publish_actions」的許可?

private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) { 
for (String string : subset) { 
    if (!superset.contains(string)) { 
     return false; 
    } 
} 
return true; 
} 

if (!isSubsetOf(PERMISSIONS, permissions)) { 
     pendingPublishReauthorization = true; 
     Session.NewPermissionsRequest newPermissionsRequest = new Session 
       .NewPermissionsRequest(this, PERMISSIONS); 
    session.requestNewPublishPermissions(newPermissionsRequest); 
     return; 
    }