Skip to content

Commit

Permalink
impr: implemented correct "items" behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Dec 21, 2015
1 parent 8cc9886 commit 0605931
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 45 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
<script src="bower_components/angular-facebook-api-factory/src/angular-facebook-api-factory.js"></script>
```

4. Use the factory `facebookFactory`.
4. Use the factory `facebookFactory`


### factory methods
Expand All @@ -25,7 +25,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
```js
facebookFactory.getPostsFromPageById({
pageId:"<PAGE_ID>",
limit:"<LIMIT>", // (optional) default: 20
limit:"<LIMIT>", // (optional) valid values: 0-100 | default: 25
until:"<UNTIL>", // (optional)
since:"<SINCE>", // (optional)
__previous:"<PREVIOUS>", // (optional)
Expand All @@ -43,7 +43,7 @@ facebookFactory.getPostsFromPageById({
```js
facebookFactory.getPhotosFromPageById({
page:"<PAGE>", // ID or name
limit:"<LIMIT>", // (optional) default: 20
limit:"<LIMIT>", // (optional) valid values: 0-100 | default: 25
before:"<BEFORE>", // (optional)
after:"<AFTER>", // (optional)
access_token:"<ACCESS_TOKEN>"
Expand All @@ -59,7 +59,7 @@ facebookFactory.getPhotosFromPageById({
```js
facebookFactory.getVideosFromPageById({
pageId:"<PAGE_ID>",
limit:"<LIMIT>", // (optional) default: 20
limit:"<LIMIT>", // (optional) valid values: 0-100 | default: 25
before:"<BEFORE>", // (optional)
after:"<AFTER>", // (optional)
access_token:"<ACCESS_TOKEN>"
Expand All @@ -75,7 +75,7 @@ facebookFactory.getVideosFromPageById({
```js
facebookFactory.getEventsFromPageById({
pageId:"<PAGE_ID>",
limit:"<LIMIT>", // (optional) default: 20
limit:"<LIMIT>", // (optional) valid values: 0-100 | default: 25
before:"<BEFORE>", // (optional)
after:"<AFTER>", // (optional)
access_token:"<ACCESS_TOKEN>"
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-facebook-api-factory",
"description": "angularjs factory for facebook json rest api requests",
"version": "0.2.0",
"version": "0.2.1",
"main": "Gruntfile.js",
"authors": [
"Jonathan Hornung"
Expand All @@ -26,6 +26,6 @@
"tests"
],
"dependencies": {
"angular": "~1.4.7"
"angular": "*"
}
}
17 changes: 7 additions & 10 deletions demo/js/app.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
var app = angular.module("app", ['jtt_facebook']);
app.controller('controller', ['$scope', 'facebookFactory', function($scope, facebookFactory) {

var _acces_token = "<YOUR_FACEBOOK_ACCESS_TOKEN>";
var _access_token = '<YOUR_FACEBOOK_ACCESS_TOKEN>';

facebookFactory.getPostsFromPageById({
page:"147615681968982",
limit:20,
access_token:_acces_token,
limit:100,
access_token:_access_token,
}).success(function(_data){
console.log("posts");
console.log(_data);
});

facebookFactory.getPhotosFromPageById({
page:"147615681968982",
limit:20,
access_token:_acces_token,
access_token:_access_token,
}).success(function(_data){
console.log("photos");
console.log(_data);
});

facebookFactory.getVideosFromPageById({
page:"147615681968982",
limit:20,
access_token:_acces_token,
access_token:_access_token,
}).success(function(_data){
console.log("videos");
console.log(_data);
});

facebookFactory.getEventsFromPageById({
page:"147615681968982",
limit:20,
access_token:_acces_token,
access_token:_access_token,
}).success(function(_data){
console.log("events");
console.log(_data);
});

facebookFactory.getPageById({
page:"147615681968982",
access_token:_acces_token,
access_token:_access_token,
}).success(function(_data){
console.log("page");
console.log(_data);
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-facebook-api-factory.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-facebook-api-factory",
"version": "0.2.0",
"version": "0.2.1",
"description": "angularjs factory for facebook json rest api requests",
"main": "Gruntfile.js",
"scripts": {
Expand Down
39 changes: 14 additions & 25 deletions src/angular-facebook-api-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,19 @@ angular.module("jtt_facebook", [])
this.getNew = function (_type, _params) {

var facebookSearchData = {
object: {},
object: {
access_token:_params.access_token || undefined,
},
url: "",
};

if (typeof _params.limit !== "undefined") {
facebookSearchData.object.limit = _params.limit;
}

switch (_type) {
case "postsFromPageById":
facebookSearchData.object = {
fields:"id,message,story,created_time,full_picture,from,link,description,type,shares,source,picture,object_id",
limit:_params.limit || 20,
access_token:_params.access_token,
};
facebookSearchData.object.fields = "id,message,story,created_time,full_picture,from,link,description,type,shares,source,picture,object_id";

facebookSearchData = this.fillDataInObjectByList(facebookSearchData, _params, [
'__paging_token', 'until', 'since', '__previous'
Expand All @@ -110,11 +112,7 @@ angular.module("jtt_facebook", [])

case "photosFromPageById":

facebookSearchData.object = {
fields:"id,created_time,from,link,picture,album,name,images",
limit:_params.limit || 20,
access_token:_params.access_token,
};
facebookSearchData.object.fields = "id,created_time,from,link,picture,album,name,images";

facebookSearchData = this.fillDataInObjectByList(facebookSearchData, _params, [
'before', 'after'
Expand All @@ -125,11 +123,7 @@ angular.module("jtt_facebook", [])

case "videosFromPageById":

facebookSearchData.object = {
fields:"id,created_time,from,description,source,picture,format,title,embed_html,permalink_url",
limit:_params.limit || 20,
access_token:_params.access_token,
};
facebookSearchData.object.fields = "id,created_time,from,description,source,picture,format,title,embed_html,permalink_url";

facebookSearchData = this.fillDataInObjectByList(facebookSearchData, _params, [
'before', 'after'
Expand All @@ -140,11 +134,7 @@ angular.module("jtt_facebook", [])

case "eventsFromPageById":

facebookSearchData.object = {
fields:"id,owner,description,picture{url},end_time,name,cover,category,place,start_time,ticket_uri",
limit:_params.limit || 20,
access_token:_params.access_token,
};
facebookSearchData.object.fields = "id,owner,description,picture{url},end_time,name,cover,category,place,start_time,ticket_uri";

facebookSearchData = this.fillDataInObjectByList(facebookSearchData, _params, [
'before', 'after'
Expand All @@ -155,10 +145,9 @@ angular.module("jtt_facebook", [])

case "pageById":

facebookSearchData.object = {
fields:"cover,link,picture{url},username,name",
access_token:_params.access_token,
};
facebookSearchData.object.fields = "cover,link,picture{url},username,name";

facebookSearchData.object.limit = undefined;

facebookSearchData.url = this.getApiBaseUrl()+_params.page+"/";
break;
Expand Down

0 comments on commit 0605931

Please sign in to comment.