我正在使用facebook sdk并在SDK的示例帮助下开发了一个代码来登录并将access_token存储到数据库中
我有2个问题:
1).当我尝试从数据库中获取access_token并将其传递给Facebook时,它不允许我使用该facebook sdk给出的示例在墙上发布,为什么会这样?
2).我经历了那个facebook.java代码,但我得到的是发布在墙上我必须打开一个对话框,因为没有其他方法可以立即传递我的消息并发布.请告诉我解决方案或电话我应该做什么,当我想在墙上张贴而不打开对话框
mPostButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String message = "Post this to my wall";
Bundle params = new Bundle();
params.putString("message", message);
mAsyncRunner.request("me/feed", params, "POST", new WallPostRequestListener());
}
});
public class WallPostRequestListener extends BaseRequestListener {
public void onComplete(final String response) {
Log.d("Facebook-Example", "Got response: " + response);
String message = "<empty>";
try {
JSONObject json = Util.parseJson(response);
message = json.getString("message");
} catch (JSONException e) {
Log.w("Facebook-Example", "JSON Error in response");
} catch (FacebookError …Run Code Online (Sandbox Code Playgroud) 我正在使用Facebook SDK在墙上发布消息.
现在我需要获取Facebook好友列表.任何人都可以帮我吗?
- 编辑 -
try {
Facebook mFacebook = new Facebook(Constants.FB_APP_ID);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
Bundle bundle = new Bundle();
bundle.putString("fields", "birthday");
mFacebook.request("me/friends", bundle);
} catch(Exception e){
Log.e(Constants.LOGTAG, " " + CLASSTAG + " Exception = "+e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
当我执行我的时候activity,我没有看到任何东西,但是LogCat有一个调试消息,如:
06-04 17:43:13.863: DEBUG/Facebook-Util(409): GET URL: https://graph.facebook.com/me/friends?format=json&fields=birthday
Run Code Online (Sandbox Code Playgroud)
当我尝试直接从浏览器访问此URL时,我收到以下错误响应:
{
error: {
type: "OAuthException"
message: "An active access token must be used to query information about the current user."
}
}
Run Code Online (Sandbox Code Playgroud)