2016-10-08 61 views
0

代碼:不能與Android的Facebook SDK共享開放圖4

String imgURL = mShareParams.getImageURL(); 
imgURL = imgURL.substring(0, imgURL.lastIndexOf("/")); 
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder().putString("og:type", "article").putString("fb:app_id",mContext.getString(R.string.facebook_app_id)).putString("og:url", mShareParams.getUrl()).putString("og:title", mShareParams.getContentTitle()).putString("og:image", imgURL).putString("og:image:type", "png").build(); 
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder().setActionType("og.likes").putObject("article", object).build(); 
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()  .setPreviewPropertyName("article").setAction(action).build(); 
if (ShareDialog.canShow(ShareLinkContent.class)) { 
    ShareDialog.show((Activity)mContext, content); 
} 

結果:

行動至少需要一個參考:你想發佈的行動是因爲它無效不指定任何引用對象。必須至少指定以下屬性之一:object。

回答

1

你的問題出現在動作類型og.likes。您應該將其更改爲:

news.publishesnews.reads