javascript 使用 Facebook API 在动态对话框中标记某人
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13841943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tag someone on a feed dialog with Facebook API
提问by
I'm using this code to share a picture on facebook.
我正在使用此代码在 facebook 上分享图片。
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>My Feed Dialog Page</title>
</head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "13899290", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
redirect_uri: 'YOUR URL HERE',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
</body>
</html>
i would like to tag someone who is on the picture. How can i achieve this ?
我想标记图片上的某个人。我怎样才能做到这一点?
Thanks in advance
提前致谢
回答by Sahil Mittal
Sorry, you cant tag people on feed dialog, but only the pictures using the tagsparam in "/photos".
抱歉,您不能在提要对话框中标记人物,但只能使用“ /photos”中的标签参数标记图片。
The Taggingconcept is available only for the Open Graph stories.
该标记的概念只为打开图的故事是可用的。
UPDATE:
更新:
You can tag a person only with a valid placeparameter(if you want to hide the place in post, give any valid page id instead), the post will look something like-
您只能使用有效的地点参数标记一个人(如果您想在帖子中隐藏该地点,请提供任何有效的页面 ID),帖子将如下所示 -
I guess, this is the only possible solution for tagging the friends in a post if you are not using the open graph
我想,如果您不使用开放图,这是在帖子中标记朋友的唯一可能解决方案
回答by Donn Lee
FB.ui method 'feed'
is the equivalent to POSTing to the /USER_ID/feed
Graph API endpoint, which creates posts. And there is currently no way to create tags for postsusing the api.
FB.ui 方法'feed'
相当于向/USER_ID/feed
Graph API 端点发送POST ,它创建了posts。并且目前无法使用 api为帖子创建标签。
Ref:
参考:
https://developers.facebook.com/bugs/247911678652789
https://developers.facebook.com/bugs/247911678652789
https://developers.facebook.com/docs/reference/api/post/
https://developers.facebook.com/docs/reference/api/post/
Alternatively, you could upload a photo to an album (or to /me/photos) and include tags for the photo:
或者,您可以将照片上传到相册(或 /me/photos)并为照片添加标签:
https://developers.facebook.com/docs/reference/api/photo/[see 'tags: create' section]
https://developers.facebook.com/docs/reference/api/photo/[参见“标签:创建”部分]
This is how I take a user uploaded file and publish it with tags:
这就是我如何获取用户上传的文件并使用标签发布它:
// Upon successful file (photo) upload.
$FILEPATH = $_FILES['file']['tmp_name'];
// upload it to FB.
$args = array(
'name' => 'Testing photo upload via php-SDK!',
'source' => '@'.realpath($FILEPATH),
'tags' => array(
array('tag_uid' => USER_ID, 'x' => 20, 'y' => 40),
)
);
$post_id = $facebook->api('/me/photos', 'post', $args);
回答by TommyBs
For the feed tagging, see my previous answers here Facebook Graph API Post with_tags option
对于提要标记,请在此处查看我之前的回答Facebook Graph API Post with_tags 选项
To summarise you basically need to use mention tagging
总而言之,您基本上需要使用提及标记
https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/
https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/
回答by dikirill
回答by Gunnar Karlsson
You can't tag images in a Post to the NewsFeed (/home) or a user's Wall (/feed). See the Graph API docsfor Posts to feed. There is no tag-related parameter.
您不能将帖子中的图像标记为 NewsFeed (/home) 或用户的墙 (/feed)。请参阅Graph API 文档以获取要馈送的帖子。没有标签相关的参数。
I'm sure i have seen this somewhere recently
我确定我最近在某个地方见过这个
What you have seen may be photo uploads, which doappear in the feed, but are not classified as posts to the newsfeed by the API. Photo uploads accept tag attributes. See Graph APi docs for Photo.
您所看到的可能是照片上传,它们确实出现在提要中,但未被 API 归类为新闻提要中的帖子。照片上传接受标签属性。有关Photo ,请参阅 Graph APi 文档。