使用 Facebook Graph API 发布嵌入的视频链接 [英] Posting an embedded video link using the Facebook Graph API
问题描述
当使用 Facebook 网络界面手动将视频链接(来自 YouTube、Vimeo 等)附加到帖子时,Facebook 会自动将该链接识别为视频,并允许生成的状态消息在线播放视频.视频在墙或新闻提要中显示为嵌入式播放器.
When manually attaching a video link (from YouTube, Vimeo, etc) to a post using the Facebook web interface, Facebook automatically recognizes the link as a video, and allows the resulting status message to play the video inline. The video is displayed as an embedded player in the Wall or News feed.
以下是手动发布后嵌入视频的外观示例.
Here's an example of what an embedded video looks like after posting manually.
使用 Graph API 发布链接时,视频未嵌入.
When posting a link using the Graph API, the video is not embedded.
curl -F 'access_token=...'
-F 'message=Link to YouTube'
-F 'link=http://www.youtube.com/watch?v=3aICB2mUu2k'
https://graph.facebook.com/me/feed
我怀疑答案与 source
参数有关,但我不确定 URL 应该在那里.指定相同的 URL 只会导致没有任何缩略图的帖子.
I suspect the answer is related to the source
argument, but I'm not sure what the URL should be there. Specifying the same URL just leads to a post with no thumbnail image whatsoever.
source:Flash 电影或视频文件的 URL嵌入在帖子中.读取流.
source: A URL to a Flash movie or video file to be embedded within the post. read_stream.
如何单独使用 Graph API 来实现相同的嵌入行为?
推荐答案
看来您必须自己提取页面中实际 swf 的 URL 和缩略图.例如,这似乎有效:
It appears that you have to extract the URLs of the actual swf in the page and the thumbnail image yourself. For example, this seems to work:
curl -F 'access_token=...'
-F 'message=Link to YouTube'
-F 'link=http://www.youtube.com/watch?v=3aICB2mUu2k'
-F 'source=http://www.youtube.com/v/3aICB2mUu2k'
-F 'picture=http://img.youtube.com/vi/3aICB2mUu2k/0.jpg'
https://graph.facebook.com/me/feed
看来您可以从页面 URL 生成有效的来源和图片.该 URL 看起来像 http://www.youtube.com/watch?v=
;获取代码(此处为 3aICB2mUu2k)并将其插入到源和
http://img 的 URL
http://www.youtube.com/e/
中.youtube.com/vi/
/0.jpg
图片.
It appears that you can generate a valid source and picture from the page URL. The URL looks like http://www.youtube.com/watch?v=<code>
; take the code (3aICB2mUu2k here) and insert it into the URLs http://www.youtube.com/e/<code>
for the source and and http://img.youtube.com/vi/<code>/0.jpg
for the picture.
这篇关于使用 Facebook Graph API 发布嵌入的视频链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!