新闻。阅读Facebook Opengraph
我这里有些麻烦,你知道雅虎吗!新闻?我想创建一个这样的小部件(当你阅读一篇文章时,它会发布在你的Facebook上) 我刚刚创建了Facebook应用程序和Open Graph,但我不知道如何将其插入我的网站,我正在使用Wordpress,我在谷歌上搜索,但我仍然不明白,希望你能帮助我新闻。阅读Facebook Opengraph,facebook,wordpress,facebook-opengraph,Facebook,Wordpress,Facebook Opengraph,我这里有些麻烦,你知道雅虎吗!新闻?我想创建一个这样的小部件(当你阅读一篇文章时,它会发布在你的Facebook上) 我刚刚创建了Facebook应用程序和Open Graph,但我不知道如何将其插入我的网站,我正在使用Wordpress,我在谷歌上搜索,但我仍然不明白,希望你能帮助我 我仍然不明白,我刚刚创建了应用程序和opengraph,还在我的标题和函数上插入了opengraph标记,但是当我试图打开帖子页面时,我得到了“出错”怎么办?您能帮助我吗?您需要通过阅读文档了解这些概念是如何工
我仍然不明白,我刚刚创建了应用程序和opengraph,还在我的标题和函数上插入了opengraph标记,但是当我试图打开帖子页面时,我得到了“出错”怎么办?您能帮助我吗?您需要通过阅读文档了解这些概念是如何工作的
POSThttps://graph.facebook.com/me/news.reads?article=[Wordpress博客中的文章对象URL]
为了完成这项工作,您需要在应用程序设置中设置内置动作类型read
:https://developers.facebook.com/apps/YOUR_APP_ID/opengraph
然后您必须具有对象集的文章
类型
然后你必须在你的WordPress博客上设置一个对象url,这些都是通过插入元标记来完成的
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#
article: http://ogp.me/ns/article#">
<meta property="fb:app_id" content="YOUR_APP_ID">
<meta property="og:type" content="article">
<meta property="og:url" content="URL of this object">
<meta property="og:site_name" content="Name of site hosting article">
<meta property="og:image" content="URL to an image">
<meta property="og:title" content="Name of article">
<meta property="og:description" content="Description of object">
<meta property="article:published_time" content="DateTime">
<meta property="article:modified_time" content="DateTime">
<meta property="article:expiration_time" content="DateTime">
<meta property="article:author" content="URL to Author object">
<meta property="article:section" content="Section of article">
<meta property="article:tag" content="Keyword">
</head>
<body>
<!-- main article body -->
</body>
</html>
一旦您确定元标记设置正确,您就需要测试前面提到的操作
POSThttps://graph.facebook.com/me/news.reads?article=[Wordpress博客中的文章对象URL]
如果一切都已设置,则应返回操作的id
然后必须使用JSSDK实现身份验证逻辑
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '[YOUR_APP_ID]', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
window.fbAsyninit=函数(){
FB.init({
appId:“[YOUR_APP_ID]”,//APP ID
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
};
//异步加载SDK
(职能(d){
var js,id='facebook jssdk';if(d.getElementById(id)){return;}
js=d.createElement('script');js.id=id;js.async=true;
js.src=“//connect.facebook.net/en_US/all.js”;
d、 getElementsByTagName('head')[0].appendChild(js);
}(文件);
和登录按钮插件
在functions.php文件中或直接在single.php和index.php页面中
在此基础上,您必须创建一个函数,以便在页面加载时调用下面的操作
<script type="text/javascript">
function readArticle()
{
FB.api(
'/me/news.reads',
'post',
{ article: 'http://yourwordpress.com/site/' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Article read was successful! Action ID: ' + response.id);
}
});
}
</script>
函数readArticle()
{
FB.api(
“/me/news.reads”,
"岗位",,
{第条:'http://yourwordpress.com/site/' },
功能(响应){
如果(!response | | response.error){
警报(“发生错误”);
}否则{
警报('文章读取成功!操作ID:'+响应.ID);
}
});
}
您需要通过阅读文档了解这些概念是如何工作的
POSThttps://graph.facebook.com/me/news.reads?article=[Wordpress博客中的文章对象URL]
为了完成这项工作,您需要在应用程序设置中设置内置动作类型read
:https://developers.facebook.com/apps/YOUR_APP_ID/opengraph
然后您必须具有对象集的文章
类型
然后你必须在你的WordPress博客上设置一个对象url,这些都是通过插入元标记来完成的
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#
article: http://ogp.me/ns/article#">
<meta property="fb:app_id" content="YOUR_APP_ID">
<meta property="og:type" content="article">
<meta property="og:url" content="URL of this object">
<meta property="og:site_name" content="Name of site hosting article">
<meta property="og:image" content="URL to an image">
<meta property="og:title" content="Name of article">
<meta property="og:description" content="Description of object">
<meta property="article:published_time" content="DateTime">
<meta property="article:modified_time" content="DateTime">
<meta property="article:expiration_time" content="DateTime">
<meta property="article:author" content="URL to Author object">
<meta property="article:section" content="Section of article">
<meta property="article:tag" content="Keyword">
</head>
<body>
<!-- main article body -->
</body>
</html>
一旦您确定元标记设置正确,您就需要测试前面提到的操作
POSThttps://graph.facebook.com/me/news.reads?article=[Wordpress博客中的文章对象URL]
如果一切都已设置,则应返回操作的id
然后必须使用JSSDK实现身份验证逻辑
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '[YOUR_APP_ID]', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
window.fbAsyninit=函数(){
FB.init({
appId:“[YOUR_APP_ID]”,//APP ID
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
};
//异步加载SDK
(职能(d){
var js,id='facebook jssdk';if(d.getElementById(id)){return;}
js=d.createElement('script');js.id=id;js.async=true;
js.src=“//connect.facebook.net/en_US/all.js”;
d、 getElementsByTagName('head')[0].appendChild(js);
}(文件);
和登录按钮插件
在functions.php文件中或直接在single.php和index.php页面中
在此基础上,您必须创建一个函数,以便在页面加载时调用下面的操作
<script type="text/javascript">
function readArticle()
{
FB.api(
'/me/news.reads',
'post',
{ article: 'http://yourwordpress.com/site/' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Article read was successful! Action ID: ' + response.id);
}
});
}
</script>
函数readArticle()
{
FB.api(
“/me/news.reads”,
"岗位",,
{第条:'http://yourwordpress.com/site/' },
功能(响应){
如果(!response | | response.error){
警报(“发生错误”);
}否则{
警报('文章读取成功!操作ID:'+响应.ID);
}
});
}
此时我必须在哪里写作?在你的Wordpress博客中发布对象URL]我现在不明白point@WawanDenFrastøtende,表示HTTP POST。您可以在cURL中完成测试或测试