我正在尝试使用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
如果我将网址复制/粘贴到我的浏览器中,我会得到一个有效的JSON响应,让我认为网址是有效的,但是,如果我查看执行记录,它会指向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);
答案 0 :(得分:0)
事实证明,<
和>
不是放入网址的有效字符。将它们更改为%3E
和%3C
,现在一切都适合全世界。