【发布时间】:2015-08-28 01:29:35
【问题描述】:
我的controller.js 上有以下代码,当我从 Facebook Graph 2.4 请求时可以使用
request.open("GET","https://graph.facebook.com/v2.4/katyperry/posts?"+access_token,true);
但是,这只返回几个字段:message、story、created_time 和 id。
我需要更多的字段:message、picture、likes、created_time、link、type、comments 和 object_id。
所以我尝试了以下方法:
request.open("GET","https://graph.facebook.com/v2.4/katyperry?fields=posts.limit(2){message,picture,likes,created_time,link,type,comments,object_id}"+access_token,true);
最后一个发给我的错误:
加载资源失败:服务器响应状态为 400(错误请求)
我在 Graph API Explorer 上测试了请求的两个选项,它工作正常。我怎样才能得到那些额外的字段?我错过了什么?
我正在添加先例代码以显示 access_token 是如何构建的:
var appID ="138429819833219";
var appSecret ="dada0a4d7f7717b0d37fd637d9e1522a";
var accessTokenRq = makeHttpRequest();
var httpString = 'https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id='+appID+'&client_secret='+appSecret;
accessTokenRq.open("GET",httpString,true);
accessTokenRq.send(null);
var access_token;
accessTokenRq.onreadystatechange = function() {
if (accessTokenRq.readyState == 4) {
access_token = accessTokenRq.responseText;
//alert("Hat geklappt - Trabajó :)");
var request = makeHttpRequest();
// the following request works
request.open("GET","https://graph.facebook.com/v2.2/katyperry/posts?"+access_token,true);
// next one don't - I checked inspector and access_token contains: 138429819833219|CewVrYOd86ctJ0HTP2X0XAS9m4o
request.open("GET","https://graph.facebook.com/v2.4/katyperry?fields=posts.limit(2){message,picture,likes,created_time,link,type,comments,object_id}"+access_token,true);
【问题讨论】:
标签: facebook-graph-api ionic-framework bad-request