我们可以在facebook上更改link(由android应用程序发布)的图像吗
我们可以在facebook上更改link(由android应用程序发布)的图像吗 我通过我的应用程序在FaceBook上发布了一些链接,但我想在FaceBook的墙上显示其他图片 我的代码是这样的我们可以在facebook上更改link(由android应用程序发布)的图像吗,android,facebook,facebook-android-sdk,Android,Facebook,Facebook Android Sdk,我们可以在facebook上更改link(由android应用程序发布)的图像吗 我通过我的应用程序在FaceBook上发布了一些链接,但我想在FaceBook的墙上显示其他图片 我的代码是这样的 Intent shareCaptionIntent = new Intent(Intent.ACTION_SEND); shareCaptionIntent.setType("image/png"); shareCaptionIntent.putExtra(Intent.EXTRA_STREAM, "
Intent shareCaptionIntent = new Intent(Intent.ACTION_SEND);
shareCaptionIntent.setType("image/png");
shareCaptionIntent.putExtra(Intent.EXTRA_STREAM, "<URL>");
//set caption
shareCaptionIntent.putExtra(Intent.EXTRA_TEXT, "example caption");
shareCaptionIntent.putExtra(Intent.EXTRA_SUBJECT, "example caption");
startActivity(Intent.createChooser(shareCaptionIntent,getString(R.string.share)));
Intent sharecaptioncontent=新的意图(Intent.ACTION\u SEND);
setType(“image/png”);
shareCaptionIntent.putExtra(Intent.EXTRA_STREAM,“”);
//设置标题
shareCaptionIntent.putExtra(Intent.EXTRA_文本,“示例标题”);
shareCaptionIntent.putExtra(Intent.EXTRA_主题,“示例标题”);
startActivity(Intent.createChooser(ShareCaptionContent,getString(R.string.share));
我还可以看到标题和描述。
如何更改图像并使说明和标题可见,请查找附加图像否您可以更改您在facebook上发布的图像的链接。当Facebook将数据存储在数据库中时,它会自动生成此链接。如果您确实需要,您可以使用Android Facebook SDK(更改发布的所有内容)来完成此操作。 或 PublishFeedHowTo示例演示(L:150-L:154)
如果您只是在进行共享,您正在共享的链接将被Facebook过滤(解析),并获取您正在共享的目标url上定义的元标记
**Using this code you can share any image from your drawable folder**
public void share()
{
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(final Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
if(!session.getPermissions().contains("publish_actions"))
{
session.requestNewPublishPermissions(new Session.NewPermissionsRequest(Aboutcampaign.this, PERMISSIONS));
}
else
{
final String message="YOUR STRING MESSAGE";
// make request to the /me API
/* Request request = Request
.newStatusUpdateRequest(Session.getActiveSession(), message, new Request.Callback() {
@Override
public void onCompleted(Response response) {
showPublishResult(message, response.getGraphObject(), response.getError());
}
});
request.executeAsync();*/
Bitmap image = BitmapFactory.decodeResource(Aboutcampaign.this.getResources(), R.drawable.product_btn);
// Bitmap BckGrnd = BitmapFactory.decodeFile(file);
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image, new Request.Callback() {
public void onCompleted(Response response) {
showPublishResult("Shared on Facebook", response.getGraphObject(), response.getError());
}
});
Bundle params = request.getParameters();
// Add the parameters you want, the caption in this case
params.putString("name", message);
// Update the request parameters
request.setParameters(params);
// Execute the request
Request.executeBatchAsync(request);
// request.executeAsync();
}
}
}
});
针对您的问题:
<meta property="og:title" content="The Rock" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
<meta property="og:description" content="A great movie with Sean Connery and Nicolas Cage" />
如果你有权更改这些元标记,那么你可以控制Facebook上显示的文章的图像、标题和描述
如需参考,请参阅以及使用Facebook调试器来lint(解析)您正在共享的url
**Using this code you can share any image from your drawable folder**
public void share()
{
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(final Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
if(!session.getPermissions().contains("publish_actions"))
{
session.requestNewPublishPermissions(new Session.NewPermissionsRequest(Aboutcampaign.this, PERMISSIONS));
}
else
{
final String message="YOUR STRING MESSAGE";
// make request to the /me API
/* Request request = Request
.newStatusUpdateRequest(Session.getActiveSession(), message, new Request.Callback() {
@Override
public void onCompleted(Response response) {
showPublishResult(message, response.getGraphObject(), response.getError());
}
});
request.executeAsync();*/
Bitmap image = BitmapFactory.decodeResource(Aboutcampaign.this.getResources(), R.drawable.product_btn);
// Bitmap BckGrnd = BitmapFactory.decodeFile(file);
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image, new Request.Callback() {
public void onCompleted(Response response) {
showPublishResult("Shared on Facebook", response.getGraphObject(), response.getError());
}
});
Bundle params = request.getParameters();
// Add the parameters you want, the caption in this case
params.putString("name", message);
// Update the request parameters
request.setParameters(params);
// Execute the request
Request.executeBatchAsync(request);
// request.executeAsync();
}
}
}
});