使用app登录在Facebook上发布应用程序请求时出错

时间:2012-01-02 10:23:24

标签: facebook apprequests

我正在尝试使用网址向用户发布apprequest:

https://graph.facebook.com/USER_ID/apprequests?message=’This is a new message from the pgm’&data='t1t2t3t4’&access_token=ACCESS_TOKEN_RECEIVED_FROM_FB&method=post

我收到以下错误:

  

响应消息错误请求响应代码400应用程序请求ID:400错误请求

     

未实施的方法   请求中的方法无效

注意:我获得了访问令牌,并且相同的网址在浏览器(Chrome)中正常工作。

我错过了什么吗?在文档中找不到多少内容!

此致

1 个答案:

答案 0 :(得分:1)

您需要对参数进行url编码。浏览器对您透明地执行此操作,这就是它在那里工作的原因。假设你正在使用php:

http_build_query(array(
  "message"      => "This is a new message from the pgm",
  "data"         => "t1t2t3t4",
  "access_token" => ACCESS_TOKEN_RECEIVED_FROM_FB,
  "method"       => "post"
));

这将通过amperstand字符处理编码和连接参数。返回值为:

message=This+is+a+new+message+from+the+pgm&data=t1t2t3t4&access_token=ACCESS_TOKEN_RECEIVED_FROM_FB&method=post