facebook-graph-api - 如何在 Google App 脚本中使用 UrlFetch 获取 Facebook 页面提要的内部字段?
问题描述
我正在尝试通过 Google App 脚本中的 urlfetch 函数获取 facebook 页面提要 json 数据的内部字段,但我得到了
无效的论点
错误。我看到了其他一些解决方案,但在我的情况下它们都不起作用这是我的代码我正在尝试获取附件内部字段,例如 fields=attachments{subattachments,url} 大括号是这里的问题,那么如何通过 urlfetchApp 解析它?
var url = 'https://graph.facebook.com'
+ '/pageneme/feed'
+'?fields=name,full_picture,message,attachments{subattachments,url}&access_token=MYACCESStoken'
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
var json = response.getContentText();
var jsondata = JSON.parse(json);
var data =jsondata.data
var pagename =data[0].name
var images= data[0].full_picture
var messages =data[0].message
var attachment = data[0].attachments
var media =data[0].subattachments
Logger.log(images); //check this and adjust following for loop and html
showFeed function accordingly
Logger.log(messages);
Logger.log(attachment);
解决方案
自己得到它感谢那些投反对票的人
我的网址中有不安全的字符。我必须对网址进行编码:
var url = 'https://graph.facebook.com'
+ '/pagename/feed'
// + '?access_token=' + encodeURIComponent(getToken());
+'?fields='+
encodeURIComponent("name,full_picture,message,attachments{subattachments,url}")
+'&access_token=token'
推荐阅读
- php - PHP :"MYSQL 连接错误,"" 也是非对象属性" 错误
- powerbi - 如何根据 Power BI 中 B 列的值计算 A 列的出现次数
- java - Cometd,Spring-security:当前经过身份验证的用户在侦听器中不可用
- opengl - 在 OpenGL 3 中设置投影模式?
- javascript - Javascript通过包含搜索词的标签子数组过滤或减少每个JSON对象
- android-studio - android studio中的片段没有在我的手机上显示仪表板
- r - For循环和gsub R
- dialogflow-es - 想要保留持久值
- azure-devops - VSTS 查询 Where 子句
- laravel - Eloquent - 检查远程关系上是否存在 id