我希望我的 android 应用程序在用户单击按钮时自动发布预设消息。预设消息将由用户设置,所以我猜这并不违反 Facebook 政策。我该怎么做呢?
问问题
4036 次
3 回答
1
private static final String[] PERMISSIONS =
new String[] {"publish_stream", "read_stream", "offline_access"};
Facebook authenticatedFacebook = new Facebook(APP_ID);
postButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
authenticatedFacebook.authorize(Tests.this, PERMISSIONS,
new TestPostListener());
}
});
public class TestPostListener implements DialogListener {
public void onComplete(Bundle values) {
try {
Log.d("Tests", "Testing request for 'me'");
String response = authenticatedFacebook.request("me");
JSONObject obj = Util.parseJson(response);
Log.d("Tests", "Testing graph API wall post");
Bundle parameters = new Bundle();
parameters.putString("message", "Amit Siddhpura");
parameters.putString("description", "Hi Mr. Amit Siddhpura");
response = authenticatedFacebook.request("me/feed", parameters,
"POST");
Log.d("Tests", "got response: " + response);
} catch (Throwable e) {
e.printStackTrace();
}
}
public void onCancel() {
}
public void onError(DialogError e) {
e.printStackTrace();
}
public void onFacebookError(FacebookError e) {
e.printStackTrace();
}
}
于 2012-08-25T14:01:15.790 回答
0
您必须在 Facebook 上创建应用程序
并从用户那里获得身份验证,然后您可以获得一个 access_token 以通过 Graph API 发布一些消息
我认为您的应用程序必须请求扩展权限:publish_stream、offline_access
github上有Facebook-Android-SDK源码,可以参考。
于 2011-01-16T12:55:18.687 回答
0
于 2011-03-17T09:31:45.590 回答