简体   繁体   English

向Facebook开放图API发出发布请求

[英]Issue making post request to Facebook open graph API

I'm trying to post on an Event wall on a user's behalf. 我正在尝试代表用户在事件墙上发布。 I have the publish_stream permission but am having trouble making a post request. 我具有publish_stream权限,但发出发布请求时遇到问题。

This doesn't work: 这不起作用:

$http.post("#{url}/#{id}/feed", {message: message, access_token: token})

But these do: 但是这些可以做到:

1) 1)

$http.get("#{url}/#{id}/feed?method=POST&message=#{message}&access_token=#{token}")

2) 2)

$http.post "#{url}/#{id}/feed?access_token=#{token}&message=#{message}"

Any idea why the Facebook API would accept the latter but reject the post method (like the API requires)? 知道Facebook API为什么会接受后者但拒绝post方法(如API要求)吗? The error I get with the $http.post is "this method requires an access_token" 我在$ http.post中遇到的错误是“此方法需要一个access_token”

I have limited idea about Facebook API but it seems that post method on $http is designed to send the data in the request body, whereas access token i think needs to be provided in querystring. 我对Facebook API的想法有限,但似乎$http上的post方法旨在在请求正文中发送数据,而我认为需要在querystring中提供访问令牌。 post method would to parameter mapping for the url if the you provide it gets the same name token as here 如果您提供的URL方法具有与此处相同的名称标记,则post方法将对URL进行参数映射

$http.post("#{url}/#{id}/feed?access_token=#{token}&message=#{message}", {message: message, access_token: token})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM