在我的 android 应用程序中,我希望用户在他们的墙上“分享”我的应用程序,所以我希望他们在他们的墙上发布预定义的内容状态。
如何自定义墙状态?(我想添加我的应用程序图标和一些耀斑文本)。
在我的 android 应用程序中,我希望用户在他们的墙上“分享”我的应用程序,所以我希望他们在他们的墙上发布预定义的内容状态。
如何自定义墙状态?(我想添加我的应用程序图标和一些耀斑文本)。
下载 Facebook SDK 并将其导入您的项目。然后使用以下代码进行授权:
public void sendtoFacebook(){
facebookClient = new Facebook("<Your_APP_ID");
facebookClient.authorize(<Current_class>.this, new AuthorizeListener());
}
现在您必须添加以下方法:
class AuthorizeListener implements DialogListener {
public void onComplete(Bundle values) {
Bundle parameters = new Bundle();
parameters.putString("message", "<Message_you_want_to_send>");// the message to post to the wall
facebookClient.dialog(<Current_class>.this, "stream.publish", parameters, this);// "stream.publish" is an API call
}
@Override
public void onFacebookError(FacebookError e) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onCancel() {
}
}
您的应用程序名称和图标将自动添加:)
在学习了 Facebook API 之后,我遇到了这个页面
所以现在我知道捆绑参数的所有选项。感谢大家的帮助!
这就是我使用 Facebook SDK 制作捆绑包以通过 facebook 对话框设置内容的方式
Bundle parameters = new Bundle();
parameters.putString("app_id", "xxxxxxx");
parameters.putString("link", "https://play.google.com/store/apps/details?id=myappistasty");
parameters.putString("name", "This is the name of the link set in app.");
parameters.putString("caption", "This is Text that is specified in bt the aoo");
parameters.putString("picture", "www.urltoimage.com);
facebook.dialog(MainActivity.this, "feed", parameters, new DialogListener() {
etc...
http://developers.facebook.com/docs/reference/dialogs/feed/ 这是向我解释了所有内容的链接,虽然它都不是在 java 中,但该表为您提供了一个好主意。
您也可以在没有 SDK 的情况下执行此操作,只需通过 Share URL:
public void shareOnFacebook(View v) {
Uri uri = Uri.parse("http://m.facebook.com/sharer.php?u=http://yourdomain/page.html&t=YourMessage");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
您只需要在您提供给共享者的 url 下的服务器上的某处放置一个内容页面/html。
如果您希望某个图像出现在共享消息中,请将其放在您共享的服务器上 html 页面的元标记中:
<link rel="image_src" type="image/jpeg" href="http://yourdomain.com/promo/image.png" />
查看带有链接图像的此类促销页面示例:http ://www.modelme.co.uk/promo/amandaharrington