通过 Graph iOS SDK 将视频分享到 Facebook
我尝试使用 Graph API 将视频上传到 Facebook。 但总是看到错误信息
(#100) 无权发布视频。
Facebook 应用程序有开发模式。我在那里创建了测试用户。我的角色是管理员。 FB 访问令牌有效。
这是我的代码:
private func upload(url: URL) {
guard let data = try? Data(contentsOf: url) else { return }
let connection = GraphRequestConnection()
connection.delegate = self
var items: [String: Any] = [:]
items["title"] = "Test title from api"
items["\(url.absoluteString)"] = data
let keys = ["value" : "EVERYONE"]
items["privacy"] = keys
let request = GraphRequest(graphPath: "me/videos", parameters: items, httpMethod: .post)
connection.add(request) { reqconnection, anyInfo, error in
print(reqconnection)
print(anyInfo)
print(error)
}
connection.start()
}
我看到了很多关于它的问题,但大多数都太旧了,不适合我。
而且我有点困惑什么文档适合在 Facebook 上发布视频。 因为在文档中我看到
视频 API 允许您在页面和群组上发布视频。不支持在用户上发布。
但也在另一个文档中看到带有路径 me/videos
的 Graph API。所以这让我有点困惑。
哪些文档适合我的情况:
从文档中我看到
您的应用应按如下方式管理权限: Graph API 请求 - 在发送 Graph API 请求之前,您应该检查必要的权限并在需要时请求它们。
在哪里可以找到publish_actions
权限?
请帮忙弄清楚如何解决这个问题。
I try to upload video to Facebook using Graph API.
But always see error message
(#100) No permission to publish the video.
Facebook app has Development mode. I created test user there. My role is admin. FB access token is valid.
Here my code here:
private func upload(url: URL) {
guard let data = try? Data(contentsOf: url) else { return }
let connection = GraphRequestConnection()
connection.delegate = self
var items: [String: Any] = [:]
items["title"] = "Test title from api"
items["\(url.absoluteString)"] = data
let keys = ["value" : "EVERYONE"]
items["privacy"] = keys
let request = GraphRequest(graphPath: "me/videos", parameters: items, httpMethod: .post)
connection.add(request) { reqconnection, anyInfo, error in
print(reqconnection)
print(anyInfo)
print(error)
}
connection.start()
}
I saw a lot of questions about it, but mostly they are too old and don't work for me.
- Share video to FB
- From thread FB Developers here - the same error, but they didn't find solution
- Also check this docs - doesn't work
Also I'm a bit confused what docs are right for post video in Facebook.
Because in docs I see
The Video API allows you to publish Videos on Pages and Groups. Publishing on Users is not supported.
but also in another docs see Graph API with path me/videos
. So it confused me a bit.
What docs are correct for my case:
From docs I see that
Your app should manage permissions as follows:
Graph API Requests - Before you send Graph API requests, you should check for necessary permissions and request them if needed.
Where can I find permission publish_actions
?
Please help to figure out how to fix that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论