自定义 Facebook 发送按钮
Custom Facebook Send button
我的网站上有这组分享按钮:
<div class='post-share'>
<a class='share-twitter' expr:href='"https://twitter.com/home?status="+data:post.url' id='tuiter' onclick='ga('send', 'event', 'click', 'tuiter');' target='_blank'><i class='fa fa-twitter'/></a>
<a class='share-google-plus' expr:href='"https://plus.google.com/share?url="+data:post.url' id='gugleplus' onclick='ga('send', 'event', 'click', 'gugleplus');' target='_blank'><i class='fa fa-google-plus'/></a>
<a class='share-pinterest' expr:href='"http://pinterest.com/pin/create/button/?url=" + data:post.url + "&media=" + data:blog.postImageUrl + "&description=" + data:post.title' id='pintresti' onclick='ga('send', 'event', 'click', 'pintresti');' target='_blank'><i class='fa fa-pinterest'/></a>
<a class='share-linkedin' expr:href='"http://www.linkedin.com/shareArticle?mini=true&url=" + data:post.url + "&title=" + data:post.title + "&summary=&source="' id='linkdini' onclick='ga('send', 'event', 'click', 'linkdini');' target='_blank'><i class='fa fa-linkedin'/></a>
我还想添加一个 Facebook 发送按钮。我在 bbc 网站上看到他们有一个自定义发送按钮:
bbc custom share buttons
我在自定义发送按钮方面遇到的困难与我在博主博客平台上工作的事实有关。
我知道我可以使用类似的东西:
<a class='share-facebook' expr:href='"http://www.facebook.com/dialog/send?u=" + data:post.url + "&title="+ data:post.title' id='tuiter' onclick='ga('send', 'event', 'click', 'tuiter');' target='_blank'><i class='fa fa-facebook'/></a>
但实际上这是行不通的。 API 错误代码:100
我也试过:
<a class='share-facebook' expr:href='"http://www.facebook.com/dialog/send?link=" + data:post.url + "&title="+ data:post.title' id='tuiter' onclick='ga('send', 'event', 'click', 'tuiter');' target='_blank'><i class='fa fa-facebook'/></a>
但是当我测试它时,我收到这条消息:"The link you followed may have expired, or the page may only be visible to an audience you're not in."
我的问题是:
- 如何为 Blogger 博客创建自定义 Facebook 发送按钮,发送 post 的默认 link(数据:post.url)
自定义发送按钮的代码如下 -
<a expr:href='"https://www.facebook.com/dialog/send?app_id=YOURAPPID&link=" + data:post.canonicalUrl + "&redirect_uri="+ data:post.canonicalUrl' >Send</a>
您需要 create a new Facebook app 才能使其正常工作。
有关发送对话框所需参数的信息,请参阅https://developers.facebook.com/docs/sharing/reference/send-dialog-
app_id - Your app's unique identifier. Required.
redirect_uri - The URL to redirect to after a person clicks a button on the dialog.
Required when using URL redirection.
link - Required parameter. The URL that is being sent in the message.
我的网站上有这组分享按钮:
<div class='post-share'>
<a class='share-twitter' expr:href='"https://twitter.com/home?status="+data:post.url' id='tuiter' onclick='ga('send', 'event', 'click', 'tuiter');' target='_blank'><i class='fa fa-twitter'/></a>
<a class='share-google-plus' expr:href='"https://plus.google.com/share?url="+data:post.url' id='gugleplus' onclick='ga('send', 'event', 'click', 'gugleplus');' target='_blank'><i class='fa fa-google-plus'/></a>
<a class='share-pinterest' expr:href='"http://pinterest.com/pin/create/button/?url=" + data:post.url + "&media=" + data:blog.postImageUrl + "&description=" + data:post.title' id='pintresti' onclick='ga('send', 'event', 'click', 'pintresti');' target='_blank'><i class='fa fa-pinterest'/></a>
<a class='share-linkedin' expr:href='"http://www.linkedin.com/shareArticle?mini=true&url=" + data:post.url + "&title=" + data:post.title + "&summary=&source="' id='linkdini' onclick='ga('send', 'event', 'click', 'linkdini');' target='_blank'><i class='fa fa-linkedin'/></a>
我还想添加一个 Facebook 发送按钮。我在 bbc 网站上看到他们有一个自定义发送按钮:
bbc custom share buttons
我在自定义发送按钮方面遇到的困难与我在博主博客平台上工作的事实有关。
我知道我可以使用类似的东西:
<a class='share-facebook' expr:href='"http://www.facebook.com/dialog/send?u=" + data:post.url + "&title="+ data:post.title' id='tuiter' onclick='ga('send', 'event', 'click', 'tuiter');' target='_blank'><i class='fa fa-facebook'/></a>
但实际上这是行不通的。 API 错误代码:100
我也试过:
<a class='share-facebook' expr:href='"http://www.facebook.com/dialog/send?link=" + data:post.url + "&title="+ data:post.title' id='tuiter' onclick='ga('send', 'event', 'click', 'tuiter');' target='_blank'><i class='fa fa-facebook'/></a>
但是当我测试它时,我收到这条消息:"The link you followed may have expired, or the page may only be visible to an audience you're not in."
我的问题是:
- 如何为 Blogger 博客创建自定义 Facebook 发送按钮,发送 post 的默认 link(数据:post.url)
自定义发送按钮的代码如下 -
<a expr:href='"https://www.facebook.com/dialog/send?app_id=YOURAPPID&link=" + data:post.canonicalUrl + "&redirect_uri="+ data:post.canonicalUrl' >Send</a>
您需要 create a new Facebook app 才能使其正常工作。
有关发送对话框所需参数的信息,请参阅https://developers.facebook.com/docs/sharing/reference/send-dialog-
app_id - Your app's unique identifier. Required.
redirect_uri - The URL to redirect to after a person clicks a button on the dialog. Required when using URL redirection.
link - Required parameter. The URL that is being sent in the message.