我可以抓住Facebook帐户的个人资料信息:
var facebookExample = angular.module('starter', ['ionic', 'ngStorage', 'ngCordova'])
facebookExample.controller("ProfileController", function($scope, $http, $localStorage, $location) {
$scope.init = function() {
if($localStorage.hasOwnProperty("accessToken") === true) {
$http.get("https://graph.facebook.com/v2.2/me", { params: { access_token: $localStorage.accessToken, fields: "id,name,gender,location,website,picture,relationship_status", format: "json" }}).then(function(result) {
$scope.profileData = result.data;
}, function(error) {
alert("There was a problem getting your profile. Check the logs for details.");
console.log(error);
});
} else {
alert("Not signed in");
$location.path("/login");
}
};
});
现在,我正试图通过以下方式获取Facebook事件的信息:
facebookExample.controller("EventController", function($scope, $http, $localStorage, $location) {
$scope.init = function() {
if($localStorage.hasOwnProperty("accessToken") === true) {
$http.get("https://graph.facebook.com/v2.2/{event-id}", { params: { access_token: $localStorage.accessToken, fields: "id, name, cover, place, description", format: "json" }}).then(function(result) {
$scope.eventData = result.data;
}, function(error) {
alert("There was a problem getting your profile. Check the logs for details.");
console.log(error);
});
} else {
alert("Not signed in");
$location.path("/login");
}
};
});
但我的eventData返回空...我正在构建一个带有cordova和angular的离子应用程序。有人可以帮忙吗?