0

我正在尝试使用 google appscript 从 facebook FQL api 获取数据。不幸的是,我不断收到以下错误:

Error encountered: Invalid argument: https://graph.facebook.com/fql?q=SELECT+post_id,share_info,comment_info,like_info,created_time+FROM+stream+WHERE+post_id+IN+(SELECT+post_id+FROM+stream+WHERE+source_id='SOME_SOURCE_ID'+AND+created_time+>+1369869370+AND+created_time+<+1377645370+ORDER+BY+created_time+DESC+LIMIT+0,100)&access_token=XXXXXXXXX

如果我将 url 复制/粘贴到浏览器中,我会得到一个有效的 JSON 响应,这让我认为 url 是有效的,但是,如果我查看执行记录,它会将我指向该var postfetch = UrlFetchApp.fetch(...)行。

这是我的代码。

var posturl = "https://graph.facebook.com/fql?q=SELECT+post_id,share_info,comment_info,like_info,created_time+FROM+stream+WHERE+post_id+IN+" +
              "(SELECT+post_id+FROM+stream+WHERE+source_id='" + source + "'+AND+created_time+>+" + istartEpoch.toString() + 
              "+AND+created_time+<+" + iendEpoch.toString() + "+ORDER+BY+created_time+DESC+LIMIT+0,100)&access_token=" + token;

var postfetch = UrlFetchApp.fetch(posturl);
var postjson = postfetch.getContentText();
var postdata = Utilities.jsonParse(postjson);
4

1 回答 1

1

事实证明,<并且>不是放入 url 的有效字符。将它们更改为%3E现在%3C世界上一切都很好。

于 2013-08-28T00:11:02.447 回答