{"id":1260,"date":"2023-03-18T09:50:26","date_gmt":"2023-03-18T01:50:26","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1260"},"modified":"2023-04-29T09:27:24","modified_gmt":"2023-04-29T01:27:24","slug":"android-use-facebook-open-graph-to-publish-and-share-images-and-text","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/android-use-facebook-open-graph-to-publish-and-share-images-and-text\/","title":{"rendered":"Android\u4f7f\u7528Facebook\u7684\u5f00\u653e\u56fe\u8c31\u53d1\u5e03\u56fe\u6587\u5206\u4eab"},"content":{"rendered":"<p>Android \u5e73\u53f0\u4e2d\u7684\u5f00\u653e\u56fe\u8c31\u52a8\u6001\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developers.facebook.com\/docs\/sharing\/opengraph\/android\">https:\/\/developers.facebook.com\/docs\/sharing\/opengraph\/android<\/a><\/p>\n<p>Object Types \u548c Action Types\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developers.facebook.com\/docs\/reference\/opengraph\">https:\/\/developers.facebook.com\/docs\/reference\/opengraph<\/a><\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-java\">private void shareBargainOrder() {\n    \/\/ Create an object\n    ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()\n            .putString(&quot;og:type&quot;, &quot;article&quot;)\n            .putString(&quot;og:url&quot;, mBargainOrder.getInviteUrl())\n            .putString(&quot;og:title&quot;, mBargainGoods.getName())\n            .putString(&quot;og:description&quot;, mBargainGoods.getDescription())\n            .putString(&quot;og:image&quot;, mBargainGoods.getPicUrl())\n            .putString(&quot;fb:app_id&quot;, mResources.getString(R.string.facebook_app_id))\n            .build();\n\n    \/\/ Create an action\n    ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()\n            .setActionType(&quot;news.publishes&quot;)\n            \/\/.setActionType(&quot;news.reads&quot;)\n            .putObject(&quot;article&quot;, object)\n            .build();\n\n    \/\/ Create the content\n    ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()\n            .setPreviewPropertyName(&quot;article&quot;)\n            .setAction(action)\n            .build();\n\n    if (ShareDialog.canShow(ShareLinkContent.class)) {\n        mShareDialog.show(content);\n    } else {\n        ShareApi.share(content, mFacebookCallback);\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Android \u5e73\u53f0\u4e2d\u7684\u5f00\u653e\u56fe\u8c31\u52a8\u6001\uff1ahttps:\/\/developers.facebook.com\/docs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[238],"class_list":["post-1260","post","type-post","status-publish","format-standard","hentry","category-android-basic","tag-facebook"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1260"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1260\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}