https://developers.facebook.com/docs/opengraph/guides/og.likes/
我需要在我的Android应用中实现类似的功能。我读到facebook的sdk无法浏览facebook feed。所以我的计划是做不喜欢的事。
有没有可用的教程?任何人都可以帮助我。
答案 0 :(得分:0)
这是一些供审核的代码
wb = (com.fb.facebook.Like) findViewById(R.id.webview);
wb.setInitialScale(1000);
((com.fb.facebook.Like) findViewById(R.id.webview))
.setApplicationKey("XXXXXXXXXXXXXXX").setUriToLike(
"https://www.facebook.com/pages/XXXXXXXXXXXXXXXXXXXX/123234231234124?fref=ts")
.load();
并通过这个
/**
* Loads like button from facebook
*/
private void loadForLikeUrl() {
loadUrl("http://www.facebook.com/plugins/like.php?api_key="
+ facebook.getAppId()
+ "&extended_social_context=false&font=arial&layout=button_count&locale=en_US"
+ "&node_type=link&sdk=joey&send=false&show_faces=false&width=450&href="
+ URLEncoder.encode(uri));
}
/**
* You must set like uri and application key for this method to work
*/
public void load() {
if (facebook != null && uri.length() > 0) {
SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(activity);
String access_token = preferences.getString("access_token", null);
long expires = preferences.getLong("access_expires", 0);
if (access_token != null) {
facebook.setAccessToken(access_token);
}
if (expires != 0) {
facebook.setAccessExpires(expires);
}
loadForLikeUrl();
}
}
这对您有所帮助。 祝你有愉快的一天...... :)
这是fbLike的完整页面代码 Like.java
答案 1 :(得分:0)
我在这里找到了解决方案:
https://developers.facebook.com/docs/reference/opengraph/action-type/og.likes
必需的权限:publish_actions
Bundle params = new Bundle();
params.putString("object", "http://samples.ogp.me/226075010839791");
Request request = new Request(
Session.getActiveSession(),
"me/og.likes",
params,
HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response