我正在尝试使用Open Graph API复制Facebook操作链接.我有以下代码段:
HTTParty.post("https://graph.facebook.com/me/feed", query: { message: "...", picture: "...", access_token: "...", actions: [{ link: "http://google.com", name: "Example" }] })
Run Code Online (Sandbox Code Playgroud)
然而它正在返回(我不知道为什么):
{"error":{"type":"OAuthException","message":"(#100) The post's action links must be valid URLs."}}
Run Code Online (Sandbox Code Playgroud)
任何人都有使用图API的操作链接的经验吗?
请注意,actions数组应该是JSON编码的,HTTParty可能不会自动/正确地执行此操作.尝试
HTTParty.post(
"https://graph.facebook.com/me/feed",
:query => {
:message => "...",
:picture => "...",
:access_token => "...",
:actions => [{ link: "http://google.com", name: "Example" }].to_json
}
)
Run Code Online (Sandbox Code Playgroud)
(假设你有一个包含了提供Array#to_json的库...)