WD Instagram Feed – Instagram Gallery - Version 1.1.2

Version Description

Fixed: Bug when saving theme data to some MySQL 5.6 databases
Changed: Pagination of hashtag feeds restored
Changed: Check and get user id on frontend if empty for some unknown reason

Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 WD Instagram Feed – Instagram Gallery
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

admin-functions.php CHANGED
@@ -177,7 +177,7 @@ function wdi_install(){
177
  }
178
 
179
  //dbDelta( $sql );
180
-
181
  $table_name = $wpdb->prefix . WDI_THEME_TABLE;
182
  $sql = "CREATE TABLE $table_name (
183
  id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -434,7 +434,7 @@ function wdi_install(){
434
  mas_thumb_user_color varchar(32) NOT NULL,
435
 
436
  UNIQUE KEY id (id)
437
- ) $charset_collate;";
438
  // dbDelta( $sql );
439
  if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
440
  //table is not created. you may create the table here.
177
  }
178
 
179
  //dbDelta( $sql );
180
+ $charset_collate2 = 'COLLATE latin1_general_ci';
181
  $table_name = $wpdb->prefix . WDI_THEME_TABLE;
182
  $sql = "CREATE TABLE $table_name (
183
  id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY,
434
  mas_thumb_user_color varchar(32) NOT NULL,
435
 
436
  UNIQUE KEY id (id)
437
+ ) $charset_collate2;";
438
  // dbDelta( $sql );
439
  if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
440
  //table is not created. you may create the table here.
frontend/views/WDIViewGalleryBox.php CHANGED
@@ -994,7 +994,7 @@ class WDIViewGalleryBox {
994
  wdi_data["<?php echo $key; ?>"]["rate"] = "<?php echo $image_row->rate; ?>";
995
  wdi_data["<?php echo $key; ?>"]["rate_count"] = "<?php echo $image_row->rate_count; ?>";
996
  wdi_data["<?php echo $key; ?>"]["hit_count"] = "<?php echo $image_row->hit_count; ?>";
997
- wdi_data["<?php echo $key; ?>"]["comments_data"] = <?php echo json_encode($image_row->comments_data); ?>;
998
  <?php
999
  }
1000
  ?>
994
  wdi_data["<?php echo $key; ?>"]["rate"] = "<?php echo $image_row->rate; ?>";
995
  wdi_data["<?php echo $key; ?>"]["rate_count"] = "<?php echo $image_row->rate_count; ?>";
996
  wdi_data["<?php echo $key; ?>"]["hit_count"] = "<?php echo $image_row->hit_count; ?>";
997
+ wdi_data["<?php echo $key; ?>"]["comments_data"] = <?php echo isset($image_row->comments_data) ? json_encode($image_row->comments_data) : 'null'; ?>;
998
  <?php
999
  }
1000
  ?>
js/wdi_frontend.js CHANGED
@@ -1,3 +1,4 @@
 
1
  if (typeof wdi_front == 'undefined') {
2
  wdi_front = {
3
  type: 'not_declared'
@@ -66,6 +67,8 @@ wdi_front.globalInit = function() {
66
 
67
  wdi_front.access_token = currentFeed['feed_row']['access_token'];
68
 
 
 
69
  currentFeed.dataStorage = []; //stores all avialable data
70
  currentFeed.dataStorageList = []; //?
71
  currentFeed.allResponseLength = 0; //?
@@ -83,6 +86,8 @@ wdi_front.globalInit = function() {
83
  currentFeed.userSortFlags = []; //array for descripbing user based filter options
84
  currentFeed.customFilterChanged = false; //flag to notice filter change, onclick on username
85
 
 
 
86
  /**
87
  * This variable describes after how many requests program will stop searching for content
88
  * this number is very important and should not be set too high, because when feed has conditional filter
@@ -144,8 +149,6 @@ wdi_front.globalInit = function() {
144
  }
145
 
146
 
147
-
148
-
149
  //initializing function for lightbox
150
  currentFeed.galleryBox = function(image_id) {
151
  wdi_spider_createpopup(wdi_url.ajax_url + '?gallery_id=' + this.feed_row['id'] + '&image_id=' + image_id, wdi_front.feed_counter, this.feed_row['lightbox_width'], this.feed_row['lightbox_height'], 1, 'testpopup', 5, this);
@@ -160,7 +163,6 @@ wdi_front.globalInit = function() {
160
 
161
  wdi_front.bindEvents(currentFeed);
162
 
163
-
164
  window['wdi_feed_' + i] = currentFeed;
165
 
166
 
@@ -185,6 +187,16 @@ wdi_front.init = function(currentFeed) {
185
  * @type {[Array}
186
  */
187
  currentFeed.feed_users = JSON.parse(currentFeed.feed_row.feed_users);
 
 
 
 
 
 
 
 
 
 
188
  } else {
189
  alert('provided feed users are invalid or obsolete for this version of plugin');
190
  return;
@@ -314,6 +326,7 @@ wdi_front.saveUserData = function(data, user, currentFeed) {
314
  /*here we are calling loadMore function out of recursion cylce, after this initial-keep call
315
  loadMore will be called with 'initial' recursivly until the desired number of photos is reached
316
  if possible*/
 
317
  wdi_front.loadMore('initial-keep', currentFeed);
318
  } else {
319
 
@@ -422,14 +435,12 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
422
  //recursively calling load more to get photos
423
  var dataLength = wdi_front.getDataLength( currentFeed );
424
 
425
-
426
 
427
- if ( dataLength < currentFeed.photoCounter && !frontendCustomFilterClicked && currentFeed.instagramRequestCounter <= currentFeed.maxConditionalFiltersRequestCount) {
428
- //console.log( 'wtf recursion' );
429
  wdi_front.loadMore( '', currentFeed );
430
 
431
  } else {
432
-
433
  }
434
 
435
 
@@ -467,13 +478,18 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
467
  wdi_front.updateUsersImages(currentFeed);
468
 
469
 
470
- /**
471
- * Enable image lazy laoding if pagination is not enabeled because pagination has option for preloading images
472
- * which is the opposide of lazy load
473
- */
 
 
474
  // if( currentFeed.feed_row.feed_display_view != 'pagination' ){
475
  // jQuery(function() {
476
- // jQuery('img.wdi_img').lazyload();
 
 
 
477
  // });
478
 
479
  // }
@@ -594,13 +610,16 @@ wdi_front.masonryDisplayFeedItems = function(data, currentFeed) {
594
  columnFlag = true;
595
  }
596
 
597
- //Binds caption opening and closing event to each image photo_title
598
  // if (currentFeed.feed_row.feed_type != 'blog_style') {
599
  // wdi_responsive.bindMasonryCaptionEvent(jQuery(this).parent().parent().parent().parent().find('.wdi_photo_title'), currentFeed);
600
  // }
601
 
602
  });
603
 
 
 
 
604
  /**
605
  * if feed type is not blog style then after displaying images assign click evetns to their captions
606
  * this part of code is a bit differenet from free version because of image lazy loading feature
@@ -615,6 +634,9 @@ wdi_front.masonryDisplayFeedItems = function(data, currentFeed) {
615
  });
616
  }
617
 
 
 
 
618
  //checks if all iamges have been succesfully loaded then it updates variables for next time use
619
  function checkLoaded() {
620
 
@@ -775,12 +797,15 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
775
  }
776
 
777
 
778
- //Binds caption opening and closing event to each image photo_title
779
  // if (currentFeed.feed_row.feed_type != 'blog_style') {
780
  // wdi_responsive.bindCaptionEvent(jQuery(this).parent().parent().parent().parent().find('.wdi_photo_title'), currentFeed);
781
  // }
782
  });
783
 
 
 
 
784
  /**
785
  * if feed type is not blog style then after displaying images assign click evetns to their captions
786
  * this part of code is a bit differenet from free version because of image lazy loading feature
@@ -795,6 +820,8 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
795
  });
796
  }
797
 
 
 
798
  //checks if all iamges have been succesfully loaded then it updates variables for next time use
799
  function checkLoaded() {
800
  if (currentFeed.wdi_load_count === currentFeed.wdi_loadedImages && currentFeed.wdi_loadedImages != 0) {
@@ -926,6 +953,7 @@ wdi_front.feedSort = function(currentFeed, load_more_number) {
926
  * and stops picking when it reaches number_of_photos limit
927
  */
928
  wdi_front.smartPicker = function(currentFeed, load_more_number) {
 
929
  var dataStorage = [];
930
  var dataLength = 0;
931
  var readyData = [];
@@ -944,14 +972,75 @@ wdi_front.smartPicker = function(currentFeed, load_more_number) {
944
  return (a['data'].length > b['data'].length) ? 1 : -1;
945
  }
946
 
 
 
 
 
 
 
 
 
 
 
 
 
947
  //sorts user data desc
948
  var usersData = currentFeed['usersData'].sort(sortOperator);
949
 
 
950
  //picks data from users and updates pagination in request json
951
  //for next time call
952
  for (var i = 0; i < usersData.length; i++) {
 
953
  remainder += perUser;
954
- if (usersData[i]['data'].length <= remainder) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
955
 
956
  var pagination = usersData[i]['pagination']['next_url'];
957
  if (usersData[i]['finished'] === undefined) {
@@ -990,83 +1079,20 @@ wdi_front.smartPicker = function(currentFeed, load_more_number) {
990
  j -= indexPuller;
991
 
992
  remainder = 0;
993
- //updating pagination
994
- if (pickedData.length != 0) {
995
- var newMaxId = pickedData[j - 1]['id'];
996
- var newMaxTagId = usersData[i]['data'][j]['id'];
997
- var oldPagination = usersData[i]['pagination'];
998
- var oldUrl = oldPagination['next_url'];
999
-
1000
- /*BUG HERE FOR HASHTAGS*/
1001
- var ifHashtag = false;
1002
-
1003
- //updating pagination url
1004
- if (oldUrl != undefined && oldUrl != null && oldUrl != '') {
1005
- var urlFragments = oldUrl.split('&');
1006
- var urlKeyValue = [];
1007
- for (var k = 0; k < urlFragments.length; k++) {
1008
-
1009
- urlKeyValue.push(urlFragments[k].split('='));
1010
- if (urlKeyValue[k][0] === 'max_id') {
1011
- urlKeyValue[k][1] = newMaxId;
1012
- }
1013
- if (urlKeyValue[k][0] === 'max_tag_id') {
1014
- urlKeyValue[k][1] = newMaxTagId.split('_')[0];
1015
-
1016
- /*FOR DISABLING JS ERROR */
1017
- ifHashtag = true;
1018
- usersData[i]["finished"] = "finished";
1019
- usersData[i]["data"] = [];
1020
- }
1021
- urlKeyValue[k] = urlKeyValue[k].join('=');
1022
- }
1023
 
1024
- var newUrl = urlKeyValue.join('&');
1025
-
1026
- /*FOR DISABLING JS ERROR */
1027
- if( ifHashtag ){
1028
- newUrl = undefined;
1029
- }
1030
-
1031
- oldPagination['next_max_id'] = newMaxId;
1032
- oldPagination['next_url'] = newUrl;
1033
-
1034
- } else {
1035
- //if pagination is not provided ie there are no more images to paginate
1036
- //it generates pagination url manually
1037
- switch (currentFeed.usersData[i]['username'][0]) {
1038
- case '#':
1039
- {
1040
-
1041
- oldPagination['next_url'] = 'https://api.instagram.com/v1/tags/' + usersData[i]['user_id'].substr(1, usersData[i]['user_id'].length) +
1042
- '/media/recent?access_token=' + currentFeed.feed_row.access_token + '&callback=jQuery111205299771015997976_1438177624435&max_tag_id=' + newMaxTagId.split('_')[0] +
1043
- '&_=1438177624450';
1044
- oldPagination['next_max_tag_id'] = newMaxId;
1045
- break;
1046
- }
1047
- default:
1048
- {
1049
 
1050
- oldPagination['next_url'] = 'https://api.instagram.com/v1/users/' + usersData[i]['user_id'] +
1051
- '/media/recent?access_token=' + currentFeed.feed_row.access_token + '&callback=jQuery111205299771015997976_1438177624435&max_id=' + newMaxId +
1052
- '&_=1438177624450';
1053
- oldPagination['next_max_id'] = newMaxId;
1054
- break;
1055
- }
1056
- }
1057
 
1058
- }
1059
- }
1060
 
1061
 
1062
  //pushes picked data into local storage
1063
  dataLength += pickedData.length;
1064
  dataStorage.push(pickedData);
1065
 
1066
- }
1067
  }
1068
-
1069
- //checks if in golbal storage user already exisit then it adds new data to user old data
1070
  //else it simple puches new user with it's data to global storage
1071
  for (i = 0; i < dataStorage.length; i++) {
1072
  if (currentFeed.dataStorage[i] === undefined) {
@@ -1180,9 +1206,11 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
1180
  customClass = 'wdi_hidden';
1181
  }
1182
 
 
 
1183
  if(currentFeed.feed_row.show_username_on_thumb == '1'){
1184
  showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
1185
- }
1186
 
1187
  //checking if caption is opend by default then add wdi_full_caption class
1188
  //only in masonry
@@ -1273,7 +1301,6 @@ wdi_front.getVideoTemplate = function(currentFeed) {
1273
  var showUsernameOnThumb = '';
1274
 
1275
 
1276
-
1277
  if (page != '') {
1278
  pagination = 'wdi_page="' + page + '"';
1279
  sourceAttr = 'src';
@@ -1286,7 +1313,7 @@ wdi_front.getVideoTemplate = function(currentFeed) {
1286
 
1287
  if(currentFeed.feed_row.show_username_on_thumb == '1'){
1288
  showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
1289
- }
1290
 
1291
  //checking if caption is opend by default then add wdi_full_caption class
1292
  //only in masonry
@@ -1364,6 +1391,7 @@ wdi_front.bindEvents = function(currentFeed) {
1364
  jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_load_more_container').on(wdi_front.clickOrTouch, function() {
1365
  //do the actual load more operation
1366
  wdi_front.loadMore(jQuery(this).find('.wdi_load_more_wrap'));
 
1367
  });
1368
  }
1369
 
@@ -1603,6 +1631,7 @@ wdi_front.loadMore = function(button, _currentFeed) {
1603
  }
1604
 
1605
  var usersData = currentFeed['usersData'];
 
1606
  currentFeed.loadMoreDataCount = currentFeed.feed_users.length;
1607
 
1608
  for (var i = 0; i < usersData.length; i++) {
@@ -1612,7 +1641,8 @@ wdi_front.loadMore = function(button, _currentFeed) {
1612
  user_id: usersData[i]['user_id'],
1613
  username: usersData[i]['username']
1614
  }
1615
- //checking if pagination url exists then load images, else skip
 
1616
  if (pagination['next_url'] != '' && pagination['next_url'] != null && pagination['next_url'] != undefined) {
1617
  var next_url = pagination['next_url'];
1618
  wdi_front.loadMoreRequest(user, next_url, currentFeed, button);
@@ -1623,6 +1653,11 @@ wdi_front.loadMore = function(button, _currentFeed) {
1623
  currentFeed.temproraryUsersData[i] = currentFeed.usersData[i];
1624
  }
1625
  currentFeed.loadMoreDataCount--;
 
 
 
 
 
1626
  continue;
1627
  }
1628
  }
@@ -1641,7 +1676,7 @@ wdi_front.loadMoreRequest = function(user, next_url, currentFeed, button) {
1641
 
1642
  currentFeed.instagram.requestByUrl(next_url, {
1643
  success: function(response) {
1644
-
1645
  if (response === '' || response == undefined || response == null) {
1646
  errorMessage = wdi_front_messages.network_error;
1647
  currentFeed.loadMoreDataCount--;
@@ -1679,6 +1714,7 @@ wdi_front.loadMoreRequest = function(user, next_url, currentFeed, button) {
1679
  currentFeed.loadMoreDataCount--;
1680
  }
1681
  }
 
1682
  //checks if load more done then displays feed
1683
  wdi_front.checkForLoadMoreDone(currentFeed, button);
1684
  }
@@ -1703,6 +1739,7 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
1703
  }
1704
  //if button is set to inital load number_of_photos photos
1705
  if (button == 'initial') {
 
1706
  /*if existing data length is smaller then load_more_number then get more objects until desired number is reached
1707
  also if it is not possible to reach the desired number (this will happen when all users has no more photos) then
1708
  displayFeed()*/
@@ -1747,6 +1784,18 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
1747
  }
1748
  }
1749
 
 
 
 
 
 
 
 
 
 
 
 
 
1750
  wdi_front.mergeData = function(array1, array2) {
1751
 
1752
 
@@ -1897,6 +1946,7 @@ wdi_front.show = function(name, currentFeed) {
1897
  switch (_this.getInputType(_user.username)) {
1898
  case 'hashtag':
1899
  {
 
1900
  currentFeed.instagram.getTagRecentMedia(_this.stripHashtag(_user.username), {
1901
  success: function(response) {
1902
  response = _this.checkMediaResponse(response);
@@ -1918,7 +1968,7 @@ wdi_front.show = function(name, currentFeed) {
1918
  },
1919
  args :{
1920
  ignoreFiltering : true,
1921
- }
1922
  });
1923
  break;
1924
  }
@@ -1944,7 +1994,7 @@ wdi_front.show = function(name, currentFeed) {
1944
  },
1945
  args :{
1946
  ignoreFiltering : true,
1947
- }
1948
  })
1949
  break;
1950
  }
@@ -2385,7 +2435,6 @@ wdi_front.getInputType = function(input) {
2385
  }
2386
  }
2387
 
2388
-
2389
  /**
2390
  * Makes a regex search of a given word returns true if symbol before and after word is space
2391
  * or word is in the beggining or in the end of string
@@ -2460,6 +2509,14 @@ wdi_front.replaceNewLines = function( string ){
2460
  }
2461
 
2462
 
 
 
 
 
 
 
 
 
2463
 
2464
  var WDIFeed = function(obj) {
2465
  this['data'] = obj['data']
@@ -2908,3 +2965,130 @@ WDIFeed.prototype.avoidDuplicateMedia = function ( response ){
2908
  return returnObject;
2909
 
2910
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  if (typeof wdi_front == 'undefined') {
3
  wdi_front = {
4
  type: 'not_declared'
67
 
68
  wdi_front.access_token = currentFeed['feed_row']['access_token'];
69
 
70
+ currentFeed.dataStorageRaw = []; //stores all getted data from instagram api
71
+
72
  currentFeed.dataStorage = []; //stores all avialable data
73
  currentFeed.dataStorageList = []; //?
74
  currentFeed.allResponseLength = 0; //?
86
  currentFeed.userSortFlags = []; //array for descripbing user based filter options
87
  currentFeed.customFilterChanged = false; //flag to notice filter change, onclick on username
88
 
89
+
90
+
91
  /**
92
  * This variable describes after how many requests program will stop searching for content
93
  * this number is very important and should not be set too high, because when feed has conditional filter
149
  }
150
 
151
 
 
 
152
  //initializing function for lightbox
153
  currentFeed.galleryBox = function(image_id) {
154
  wdi_spider_createpopup(wdi_url.ajax_url + '?gallery_id=' + this.feed_row['id'] + '&image_id=' + image_id, wdi_front.feed_counter, this.feed_row['lightbox_width'], this.feed_row['lightbox_height'], 1, 'testpopup', 5, this);
163
 
164
  wdi_front.bindEvents(currentFeed);
165
 
 
166
  window['wdi_feed_' + i] = currentFeed;
167
 
168
 
187
  * @type {[Array}
188
  */
189
  currentFeed.feed_users = JSON.parse(currentFeed.feed_row.feed_users);
190
+
191
+ /**
192
+ * Check if feed user has no id for some reason then update user
193
+ * and after updating them initialize feed
194
+ */
195
+ if ( wdi_front.updateUsersIfNecessary( currentFeed ) ){
196
+ return;
197
+ };
198
+
199
+
200
  } else {
201
  alert('provided feed users are invalid or obsolete for this version of plugin');
202
  return;
326
  /*here we are calling loadMore function out of recursion cylce, after this initial-keep call
327
  loadMore will be called with 'initial' recursivly until the desired number of photos is reached
328
  if possible*/
329
+
330
  wdi_front.loadMore('initial-keep', currentFeed);
331
  } else {
332
 
435
  //recursively calling load more to get photos
436
  var dataLength = wdi_front.getDataLength( currentFeed );
437
 
 
438
 
439
+ if ( dataLength < currentFeed.photoCounter && !frontendCustomFilterClicked && currentFeed.instagramRequestCounter <= currentFeed.maxConditionalFiltersRequestCount && !wdi_front.allDataHasFinished( currentFeed )) {
 
440
  wdi_front.loadMore( '', currentFeed );
441
 
442
  } else {
443
+ wdi_front.allImagesLoaded(currentFeed);
444
  }
445
 
446
 
478
  wdi_front.updateUsersImages(currentFeed);
479
 
480
 
481
+
482
+
483
+ // /**
484
+ // * Enable image lazy laoding if pagination is not enabeled because pagination has option for preloading images
485
+ // * which is the opposide of lazy load
486
+ // */
487
  // if( currentFeed.feed_row.feed_display_view != 'pagination' ){
488
  // jQuery(function() {
489
+ // jQuery('img.wdi_img').lazyload({
490
+ // skip_invisible : false,
491
+ // threshold : 400
492
+ // });
493
  // });
494
 
495
  // }
610
  columnFlag = true;
611
  }
612
 
613
+ //Binds caption opening and closing event to each image photo_title/mmmmmm
614
  // if (currentFeed.feed_row.feed_type != 'blog_style') {
615
  // wdi_responsive.bindMasonryCaptionEvent(jQuery(this).parent().parent().parent().parent().find('.wdi_photo_title'), currentFeed);
616
  // }
617
 
618
  });
619
 
620
+
621
+
622
+
623
  /**
624
  * if feed type is not blog style then after displaying images assign click evetns to their captions
625
  * this part of code is a bit differenet from free version because of image lazy loading feature
634
  });
635
  }
636
 
637
+
638
+
639
+
640
  //checks if all iamges have been succesfully loaded then it updates variables for next time use
641
  function checkLoaded() {
642
 
797
  }
798
 
799
 
800
+ // //Binds caption opening and closing event to each image photo_title/mmmmmm
801
  // if (currentFeed.feed_row.feed_type != 'blog_style') {
802
  // wdi_responsive.bindCaptionEvent(jQuery(this).parent().parent().parent().parent().find('.wdi_photo_title'), currentFeed);
803
  // }
804
  });
805
 
806
+
807
+
808
+
809
  /**
810
  * if feed type is not blog style then after displaying images assign click evetns to their captions
811
  * this part of code is a bit differenet from free version because of image lazy loading feature
820
  });
821
  }
822
 
823
+
824
+
825
  //checks if all iamges have been succesfully loaded then it updates variables for next time use
826
  function checkLoaded() {
827
  if (currentFeed.wdi_load_count === currentFeed.wdi_loadedImages && currentFeed.wdi_loadedImages != 0) {
953
  * and stops picking when it reaches number_of_photos limit
954
  */
955
  wdi_front.smartPicker = function(currentFeed, load_more_number) {
956
+
957
  var dataStorage = [];
958
  var dataLength = 0;
959
  var readyData = [];
972
  return (a['data'].length > b['data'].length) ? 1 : -1;
973
  }
974
 
975
+ var sortOperator1 = function(a, b){
976
+ return (a.length() > b.length()) ? 1 : -1;
977
+ }
978
+
979
+
980
+
981
+ // storing user data in global dataStoreageRaw variable
982
+ currentFeed.storeRawData( currentFeed.usersData, 'dataStorageRaw' );
983
+
984
+ //dataStorageRaw
985
+ var dataStorageRaw = currentFeed['dataStorageRaw'].sort( sortOperator1 );
986
+
987
  //sorts user data desc
988
  var usersData = currentFeed['usersData'].sort(sortOperator);
989
 
990
+
991
  //picks data from users and updates pagination in request json
992
  //for next time call
993
  for (var i = 0; i < usersData.length; i++) {
994
+
995
  remainder += perUser;
996
+
997
+ /* if data is less then amount for each user then pick all data */
998
+ if( dataStorageRaw[i].length() <= remainder ){
999
+
1000
+ /* update remainder */
1001
+ remainder -= dataStorageRaw[i].length();
1002
+
1003
+ /* get and store data */
1004
+ dataStorage.push( dataStorageRaw[i].getData( dataStorageRaw[i].length() ) );
1005
+ /* update data length */
1006
+ dataLength += dataStorage[ dataStorage.length - 1 ].length;
1007
+
1008
+
1009
+ }else{
1010
+ if( dataLength + remainder > number_of_photos ){
1011
+ remainder = number_of_photos - dataLength;
1012
+ }
1013
+
1014
+ var pickedData = [];
1015
+
1016
+
1017
+ if (currentFeed['auto_trigger'] === false) {
1018
+ pickedData = pickedData.concat( dataStorageRaw[i].getData( remainder ) );
1019
+ } else {
1020
+ if (pickedData.length + wdi_front.getDataLength(currentFeed) + wdi_front.getDataLength(currentFeed, dataStorage) < currentFeed['feed_row']['number_of_photos']) {
1021
+ pickedData = pickedData.concat( dataStorageRaw[i].getData( remainder ) );
1022
+ }
1023
+ }
1024
+
1025
+ remainder = 0;
1026
+
1027
+ dataLength += pickedData.length;
1028
+ dataStorage.push( pickedData );
1029
+
1030
+
1031
+ }
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+ /*if (usersData[i]['data'].length <= remainder) {
1044
 
1045
  var pagination = usersData[i]['pagination']['next_url'];
1046
  if (usersData[i]['finished'] === undefined) {
1079
  j -= indexPuller;
1080
 
1081
  remainder = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1082
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1083
 
 
 
 
 
 
 
 
1084
 
1085
+ //updating pagination
1086
+
1087
 
1088
 
1089
  //pushes picked data into local storage
1090
  dataLength += pickedData.length;
1091
  dataStorage.push(pickedData);
1092
 
1093
+ }*/
1094
  }
1095
+ //checks if in golbal storage user already exisit then it adds new data to user old data
 
1096
  //else it simple puches new user with it's data to global storage
1097
  for (i = 0; i < dataStorage.length; i++) {
1098
  if (currentFeed.dataStorage[i] === undefined) {
1206
  customClass = 'wdi_hidden';
1207
  }
1208
 
1209
+
1210
+
1211
  if(currentFeed.feed_row.show_username_on_thumb == '1'){
1212
  showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
1213
+ }
1214
 
1215
  //checking if caption is opend by default then add wdi_full_caption class
1216
  //only in masonry
1301
  var showUsernameOnThumb = '';
1302
 
1303
 
 
1304
  if (page != '') {
1305
  pagination = 'wdi_page="' + page + '"';
1306
  sourceAttr = 'src';
1313
 
1314
  if(currentFeed.feed_row.show_username_on_thumb == '1'){
1315
  showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
1316
+ }
1317
 
1318
  //checking if caption is opend by default then add wdi_full_caption class
1319
  //only in masonry
1391
  jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_load_more_container').on(wdi_front.clickOrTouch, function() {
1392
  //do the actual load more operation
1393
  wdi_front.loadMore(jQuery(this).find('.wdi_load_more_wrap'));
1394
+
1395
  });
1396
  }
1397
 
1631
  }
1632
 
1633
  var usersData = currentFeed['usersData'];
1634
+
1635
  currentFeed.loadMoreDataCount = currentFeed.feed_users.length;
1636
 
1637
  for (var i = 0; i < usersData.length; i++) {
1641
  user_id: usersData[i]['user_id'],
1642
  username: usersData[i]['username']
1643
  }
1644
+
1645
+ //checking if pagination url exists then load images, else skip
1646
  if (pagination['next_url'] != '' && pagination['next_url'] != null && pagination['next_url'] != undefined) {
1647
  var next_url = pagination['next_url'];
1648
  wdi_front.loadMoreRequest(user, next_url, currentFeed, button);
1653
  currentFeed.temproraryUsersData[i] = currentFeed.usersData[i];
1654
  }
1655
  currentFeed.loadMoreDataCount--;
1656
+
1657
+
1658
+ wdi_front.checkForLoadMoreDone(currentFeed, button);
1659
+
1660
+
1661
  continue;
1662
  }
1663
  }
1676
 
1677
  currentFeed.instagram.requestByUrl(next_url, {
1678
  success: function(response) {
1679
+
1680
  if (response === '' || response == undefined || response == null) {
1681
  errorMessage = wdi_front_messages.network_error;
1682
  currentFeed.loadMoreDataCount--;
1714
  currentFeed.loadMoreDataCount--;
1715
  }
1716
  }
1717
+
1718
  //checks if load more done then displays feed
1719
  wdi_front.checkForLoadMoreDone(currentFeed, button);
1720
  }
1739
  }
1740
  //if button is set to inital load number_of_photos photos
1741
  if (button == 'initial') {
1742
+
1743
  /*if existing data length is smaller then load_more_number then get more objects until desired number is reached
1744
  also if it is not possible to reach the desired number (this will happen when all users has no more photos) then
1745
  displayFeed()*/
1784
  }
1785
  }
1786
 
1787
+ wdi_front.allDataHasFinished = function( currentFeed ){
1788
+ var c = 0;
1789
+ for( var j = 0; j < currentFeed.dataStorageRaw.length; j++ ){
1790
+ if( currentFeed.dataStorageRaw[j].length() == 0 && currentFeed.dataStorageRaw[j].locked == true ){
1791
+ c++;
1792
+ }
1793
+ }
1794
+
1795
+ return (c == currentFeed.dataStorageRaw.length);
1796
+ }
1797
+
1798
+
1799
  wdi_front.mergeData = function(array1, array2) {
1800
 
1801
 
1946
  switch (_this.getInputType(_user.username)) {
1947
  case 'hashtag':
1948
  {
1949
+
1950
  currentFeed.instagram.getTagRecentMedia(_this.stripHashtag(_user.username), {
1951
  success: function(response) {
1952
  response = _this.checkMediaResponse(response);
1968
  },
1969
  args :{
1970
  ignoreFiltering : true,
1971
+ }
1972
  });
1973
  break;
1974
  }
1994
  },
1995
  args :{
1996
  ignoreFiltering : true,
1997
+ }
1998
  })
1999
  break;
2000
  }
2435
  }
2436
  }
2437
 
 
2438
  /**
2439
  * Makes a regex search of a given word returns true if symbol before and after word is space
2440
  * or word is in the beggining or in the end of string
2509
  }
2510
 
2511
 
2512
+ wdi_front.isEmptyObject = function(obj){
2513
+ for(var prop in obj) {
2514
+ if(obj.hasOwnProperty(prop))
2515
+ return false;
2516
+ }
2517
+ return true
2518
+ }
2519
+
2520
 
2521
  var WDIFeed = function(obj) {
2522
  this['data'] = obj['data']
2965
  return returnObject;
2966
 
2967
  }
2968
+
2969
+
2970
+ /* stores data from objects array into global variable */
2971
+ WDIFeed.prototype.storeRawData = function( objects, variable ){
2972
+ var _this = this;
2973
+ if( typeof this[variable] == "object" && typeof this[variable].length == "number"){
2974
+ //checks if in golbal storage user already exisit then it adds new data to user old data
2975
+ //else it simple puches new user with it's data to global storage
2976
+ for( var i = 0; i < objects.length; i++ ){
2977
+
2978
+
2979
+ var hash_id = "";
2980
+
2981
+ if( wdi_front.isHashtag( objects[i].user_id )){
2982
+ hash_id = objects[i].pagination.next_max_tag_id;
2983
+ }else{
2984
+ hash_id = objects[i].pagination.next_max_id;
2985
+ if ( typeof hash_id == "undefined"){
2986
+ hash_id = "";
2987
+ }
2988
+ }
2989
+
2990
+ if( typeof this[variable][i] == "undefined"){
2991
+ this[variable].push( {
2992
+ data : objects[i].data,
2993
+ index: 0,
2994
+ locked: false,
2995
+ hash_id: hash_id,
2996
+ usersDataFinished: false,
2997
+ userId : objects[i].user_id,
2998
+ length: function(){
2999
+ return this.data.length - this.index;
3000
+ },
3001
+ getData: function( num ){
3002
+ var data = this.data.slice( this.index, this.index+num);
3003
+ this.index += Math.min( num, this.length() );
3004
+
3005
+ if( this.index == this.data.length && this.locked == true && this.usersDataFinished == false){
3006
+
3007
+ for( var j = 0; j < _this.usersData.length; j++ ){
3008
+ if( _this.usersData[j]['user_id'] == this.userId ){
3009
+ _this.usersData[j].finished = "finished";
3010
+ this.usersDataFinished = true;
3011
+ break;
3012
+ }
3013
+ }
3014
+ }
3015
+ return data;
3016
+ }
3017
+ } );
3018
+ }else{
3019
+ if( this[variable][i].locked == false ){
3020
+
3021
+ if( hash_id != this[variable][i].hash_id){
3022
+ this[variable][i].data = this[variable][i].data.concat( objects[i].data );
3023
+ this[variable][i].hash_id = hash_id;
3024
+ }else{
3025
+ this[variable][i].locked = true;
3026
+
3027
+ }
3028
+ }
3029
+
3030
+ }
3031
+ }
3032
+ }
3033
+
3034
+ }
3035
+
3036
+
3037
+ wdi_front.updateUsersIfNecessary = function(currentFeed){
3038
+ var users = currentFeed.feed_users;
3039
+ var ifUpdateNecessary = false;
3040
+
3041
+ for( var i = 0; i < users.length; i++ ){
3042
+ if( "#" == users[i].username.substr(0,1) ){
3043
+ users[i].id = users[i].username;
3044
+ continue;
3045
+ }
3046
+ if( "" == users[i].id || 'username' == users[i].id){
3047
+
3048
+ ifUpdateNecessary = true;
3049
+ currentFeed.instagram.searchForUsersByName( users[i].username, {
3050
+ success: function(res){
3051
+ if( res.meta.code == 200 && res.data.length > 0){
3052
+
3053
+ var found = false;
3054
+
3055
+ for( var k = 0; k < res.data.length; k++ ){
3056
+ if( res.data[k].username == res.args.username){
3057
+ found = true;
3058
+ break;
3059
+ }
3060
+ }
3061
+
3062
+ if( found ){
3063
+ for( var j = 0; j < users.length; j++ ){
3064
+ if( res.data[k].username == users[j].username ){
3065
+ users[j].id = res.data[k].id;
3066
+ }
3067
+ }
3068
+ }
3069
+
3070
+
3071
+
3072
+ }
3073
+
3074
+ var noid_user_left = false;
3075
+ for(var m = 0; m < users.length; m++ ){
3076
+ if(users[m].id == "" || users[m].id == "username"){
3077
+ noid_user_left = true;
3078
+ break;
3079
+ }
3080
+ }
3081
+ if( !noid_user_left ){
3082
+ currentFeed.feed_row.feed_users = JSON.stringify( users );
3083
+ wdi_front.init( currentFeed );
3084
+ }
3085
+
3086
+ },
3087
+ username : users[i].username
3088
+ } );
3089
+ }
3090
+ }
3091
+
3092
+ return ifUpdateNecessary;
3093
+ }
3094
+
js/wdi_instagram.js CHANGED
@@ -11,11 +11,11 @@
11
  *
12
  *
13
  * Methods:
14
- * getSelfInfo = function( args ) : Get information about the owner of the access_token.
15
- * searchForUsersByName = function( username, args ) : Get a list of users matching the query.
16
- * searchForTagsByName = function(tagname, args) : Search for tags by name.
17
- * getTagRecentMedia = function(tagname, args) : Gets recent media based on tagname
18
- *
19
  */
20
 
21
 
@@ -25,16 +25,16 @@
25
  * @type {Object}
26
  */
27
  // var args = {
28
- // access_tokens: ['227416602.145c5c2.302096fa9b3b4a8bbe0cee9341a6d7f5'],
29
- // filters: [{
30
- // where: 'getTagRecentMedia',
31
- // what: function(r) {
32
- // return r;
33
- // },
34
  // }, {
35
- // where: 'searchForUsersByName',
36
- // what: 'bbb',
37
- // }],
38
  // }
39
 
40
 
@@ -48,1276 +48,1279 @@
48
  * @param {Object} [args.filters[i] ] [ filter object which contain 'where' : 'what' pair ]
49
  * @param {String} [args.filters.filter[i].where] [name of function where filter must be applied]
50
  * @param {String or Array} [args.filters.filter[i].what] [name of filtering function,
51
- * if function is in global scope then it should be name of the funtion
52
- * else if function in method of some object then it should be an array
53
- * ['parent_object_name','filtering_function_name']]
54
  */
55
  function WDIInstagram(args) {
56
 
57
- this.access_tokens = [];
58
- this.filters = [];
59
- if (typeof args != 'undefined') {
60
- if (typeof args.access_tokens != 'undefined') {
61
- this.access_tokens = args.access_tokens;
62
- }
63
- if (typeof args.filters != 'undefined') {
64
- this.filters = args.filters;
65
- }
66
- }
67
-
68
-
69
- var _this = this;
70
-
71
- /**
72
- * Default object for handling status codes
73
- * @type {Object}
74
- */
75
- this.statusCode = {
76
- 429 : function(){
77
- console.log(' 429: Too many requests try after one hour' );
78
- },
79
- }
80
-
81
- /**
82
- * gets filter function defined for specific method
83
- * this function is internal function and cannot be called outside of this object
84
- *
85
- * @param {String} methodName [name of WDIInstagram method]
86
- * @return {Function} [filtering function for {methodName}]
87
- */
88
- this.getFilter = function(methodName) {
89
- var filters = _this.filters;
90
- if (typeof filters == "undefined") {
91
- return false;
92
- }
93
-
94
- for (var i = 0; i < filters.length; i++) {
95
- if (filters[i].where == methodName) {
96
-
97
- if (typeof filters[i].what == 'object' && filters[i].what.length == 2) {
98
- if (typeof window[filters[i].what[0]] != 'undefined') {
99
- if (typeof window[filters[i].what[0]][filters[i].what[1]] == 'function') {
100
- return window[filters[i].what[0]][filters[i].what[1]];
101
- }
102
- }
103
- } else if (typeof filters[i].what == 'string') {
104
- if (typeof window[filters[i].what] == 'function') {
105
- return window[filters[i].what];
106
- }
107
- } else if (typeof filters[i].what == 'function') {
108
- return filters[i].what;
109
- } else {
110
- return false;
111
- }
112
- }
113
- }
114
- return false;
115
- }
116
-
117
- function getAccessToken() {
118
- var access_tokens = _this.access_tokens,
119
- index = parseInt(Math.random(0, 1) * access_tokens.length);
120
- return access_tokens[index];
121
- }
122
-
123
- /**
124
- * Adds access token to this.access_tokens array
125
- * non string values are not allowed
126
- * @param {String} token [Instagram API access token]
127
- */
128
- this.addToken = function(token) {
129
- if (typeof token == 'string') {
130
- _this.access_tokens.push(token);
131
- }
132
- }
133
-
134
- /**
135
- * Gets recent media based on tagname
136
- *
137
- *
138
- * @definition success_callback => which function to call in case of success
139
- * @definition error_callback => which function to call in case of error
140
- * @definition media_count => number of media to request
141
- * @definition min_tag_id => Return media before this min_tag_id.
142
- * @definition max_tag_id => Return media after this max_tag_id.
143
- * @definition statusCode => StatusCode object.
144
- *
145
- * @param tagname => A valid tag name without a leading #. (eg. snowy, nofilter)
146
- * @param args = {
147
- * success : 'success_callback',
148
- * error : 'error_callback',
149
- * statusCode : statusCode
150
- * count : 'media_count',
151
- * min_tag_id : 'min_tag_id',
152
- * max_tag_id : 'max_tag_id',
153
- * args : arguments to be passed to filtering function
154
- * }
155
- *
156
- *
157
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
158
- * or you can pass as callback function an anonymous function
159
- *
160
- *
161
- * @return object of founded media
162
- */
163
- this.getTagRecentMedia = function(tagname, args) {
164
- var instagram = this,
165
- noArgument = false,
166
- successFlag = false,
167
- statusCode = this.statusCode;
168
- errorFlag = false,
169
- argFlag = false,
170
- filter = this.getFilter('getTagRecentMedia');
171
-
172
- baseUrl = 'https://api.instagram.com/v1/tags/' + tagname + '/media/recent?access_token=' + getAccessToken();
173
-
174
-
175
- if (typeof args == 'undefined' || args.length === 0) {
176
- noArgument = true;
177
- } else {
178
-
179
- if ('success' in args) {
180
- successFlag = true;
181
- }
182
- if( 'statusCode' in args ){
183
- statusCode = args['statusCode'];
184
- }
185
- if ('error' in args) {
186
- errorFlag = true;
187
- }
188
  //
189
- if ( 'args' in args ){
190
- argFlag = true;
191
- }else{
192
- args.args = {};
193
- }
194
  //
195
- if ('count' in args) {
196
- args['count'] = parseInt(args['count']);
197
- if (!Number.isInteger(args['count']) || args['count'] <= 0) {
198
- args.count = 33;
199
- }
200
- } else {
201
- args.count = 33;
202
- }
203
-
204
- baseUrl += '&count=' + args.count;
205
-
206
- if ('min_tag_id' in args) {
207
- baseUrl += '&min_tag_id=' + args.min_tag_id;
208
- }
209
-
210
- if ('max_tag_id' in args) {
211
- baseUrl += '&max_tag_id=' + args.max_tag_id;
212
- }
213
- }
214
-
215
- jQuery.ajax({
216
- type: 'POST',
217
- url: baseUrl,
218
- dataType: 'jsonp',
219
- success: function(response) {
220
- if (successFlag) {
221
- if (typeof args.success == 'object' && args.success.length == 2) {
222
- if (typeof window[args.success[0]] != 'undefined') {
223
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
224
- if (filter) {
225
- response = filter(response,instagram.filterArguments, args.args);
226
- }
227
- window[args.success[0]][args.success[1]](response);
228
- }
229
- }
230
-
231
- } else if (typeof args.success == 'string') {
232
- if (typeof window[args.success] == 'function') {
233
- if (filter) {
234
- response = filter(response,instagram.filterArguments, args.args);
235
- }
236
- window[args.success](response);
237
- }
238
- } else if (typeof args.success == 'function') {
239
- if (filter) {
240
- response = filter(response,instagram.filterArguments, args.args);
241
- }
242
- args.success(response);
243
- }
244
- }
245
- },
246
- error: function(response) {
247
- if (errorFlag) {
248
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
249
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
250
- window[args['error'][0]][args['error'][1]](response);
251
- }
252
- } else if (typeof args['error'] == 'string') {
253
- if (typeof window[args['error']] == 'function') {
254
- window[args['error']](response);
255
- }
256
- } else if (typeof args['error'] == 'function') {
257
- args['error'](response);
258
- }
259
- }
260
- },
261
- statusCode : statusCode
262
- });
263
-
264
- }
265
-
266
-
267
- /**
268
- * Search for tags by name.
269
- *
270
- *
271
- * @definition success_callback => which function to call in case of success
272
- * @definition error_callback => which function to call in case of error
273
- * @definition statusCode => StatusCode object.
274
- *
275
- * @param tagname => A valid tag name without a leading #. (eg. snowy, nofilter)
276
- * @param args = {
277
- * success: 'success_callback',
278
- * error: 'error_callback',
279
- * statusCode : statusCode,
280
- * }
281
- *
282
- *
283
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
284
- * or you can pass as callback function an anonymous function
285
- *
286
- *
287
- * @return object of founded media
288
- */
289
-
290
- this.searchForTagsByName = function(tagname, args) {
291
- var instagram = this,
292
- noArgument = false,
293
- successFlag = false,
294
- statusCode = this.statusCode;
295
- errorFlag = false;
296
- filter = this.getFilter('searchForTagsByName');
297
-
298
- if (typeof args == 'undefined' || args.length === 0) {
299
- noArgument = true;
300
- } else {
301
- if ('success' in args) {
302
- successFlag = true;
303
- }
304
- if ('error' in args) {
305
- errorFlag = true;
306
- }
307
- if( 'statusCode' in args ){
308
- statusCode = args['statusCode'];
309
- }
310
- }
311
-
312
-
313
- jQuery.ajax({
314
- type: 'POST',
315
- url: 'https://api.instagram.com/v1/tags/search?q=' + tagname + '&access_token=' + getAccessToken(),
316
- dataType: 'jsonp',
317
- success: function(response) {
318
- if (successFlag) {
319
- if (typeof args.success == 'object' && args.success.length == 2) {
320
- if (typeof window[args.success[0]] != 'undefined') {
321
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
322
- if (filter) {
323
- response = filter(response,instagram.filterArguments);
324
- }
325
- window[args.success[0]][args.success[1]](response);
326
- }
327
- }
328
- } else if (typeof args.success == 'string') {
329
- if (typeof window[args.success] == 'function') {
330
- if (filter) {
331
- response = filter(response,instagram.filterArguments);
332
- }
333
- window[args.success](response);
334
- }
335
- } else if (typeof args.success == 'function') {
336
- if (filter) {
337
- response = filter(response,instagram.filterArguments);
338
- }
339
- args.success(response);
340
- }
341
- }
342
- },
343
- error: function(response) {
344
- if (errorFlag) {
345
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
346
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
347
- window[args['error'][0]][args['error'][1]](response);
348
- }
349
- } else if (typeof args['error'] == 'string') {
350
- if (typeof window[args['error']] == 'function') {
351
- window[args['error']](response);
352
- }
353
- } else if (typeof args['error'] == 'function') {
354
- args['error'](response);
355
- }
356
- }
357
- },
358
- statusCode: statusCode
359
- });
360
- }
361
-
362
-
363
-
364
- /**
365
- * Get a list of users matching the query.
366
- *
367
- *
368
- * @definition success_callback => which function to call in case of success
369
- * @definition error_callback => which function to call in case of error
370
- * @definition statusCode => StatusCode object.
371
- *
372
- * @param username
373
- * @param args = {
374
- * success: 'success_callback',
375
- * error: 'error_callback',
376
- * statusCode : statusCode
377
- * }
378
- *
379
- *
380
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
381
- * or you can pass as callback function an anonymous function
382
- *
383
- *
384
- * @return object of founded users
385
- */
386
- this.searchForUsersByName = function(username, args) {
387
- var instagram = this,
388
- noArgument = false,
389
- successFlag = false,
390
- statusCode = this.statusCode,
391
- errorFlag = false,
392
- filter = this.getFilter('searchForUsersByName');
393
-
394
- if (typeof args == 'undefined' || args.length === 0) {
395
- noArgument = true;
396
- } else {
397
- if ('success' in args) {
398
- successFlag = true;
399
- }
400
- if ('error' in args) {
401
- errorFlag = true;
402
- }
403
- if( 'statusCode' in args ){
404
- statusCode = args['statusCode'];
405
- }
406
- }
407
-
408
-
409
- jQuery.ajax({
410
- type: 'POST',
411
- dataType: 'jsonp',
412
- url: 'https://api.instagram.com/v1/users/search?q=' + username + '&access_token=' + getAccessToken(),
413
- success: function(response) {
414
- if (successFlag) {
415
- if (typeof args.success == 'object' && args.success.length == 2) {
416
- if (typeof window[args.success[0]] != 'undefined') {
417
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
418
- if (filter) {
419
- response = filter(response,instagram.filterArguments);
420
- }
421
- window[args.success[0]][args.success[1]](response);
422
- }
423
- }
424
- } else if (typeof args.success == 'string') {
425
- if (typeof window[args.success] == 'function') {
426
- if (filter) {
427
- response = filter(response,instagram.filterArguments);
428
- }
429
- window[args.success](response);
430
- }
431
- } else if (typeof args.success == 'function') {
432
- if (filter) {
433
- response = filter(response,instagram.filterArguments);
434
- }
435
- args.success(response);
436
- }
437
- }
438
- },
439
- error: function(response) {
440
- if (errorFlag) {
441
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
442
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
443
- window[args['error'][0]][args['error'][1]](response);
444
- }
445
- } else if (typeof args['error'] == 'string') {
446
- if (typeof window[args['error']] == 'function') {
447
- window[args['error']](response);
448
- }
449
- } else if (typeof args['error'] == 'function') {
450
- args['error'](response);
451
- }
452
- }
453
- },
454
- statusCode : this.statusCode
455
-
456
- });
457
- }
458
-
459
-
460
-
461
- /**
462
- * Get the list of recent media liked by the owner of the access_token.
463
- *
464
- *
465
- * @definition success_callback => which function to call in case of success
466
- * @definition error_callback => which function to call in case of error
467
- * @definition statusCode => StatusCode object.
468
- * @param args = {
469
- * success: 'success_callback',
470
- * error: 'error_callback',
471
- * statusCode : statusCode
472
- * }
473
- *
474
- *
475
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
476
- * or you can pass as callback function an anonymous function
477
- *
478
- *
479
- * @return object of founded media
480
- */
481
-
482
- this.getRecentLikedMedia = function(args) {
483
- var instagram = this,
484
- noArgument = false,
485
- successFlag = false,
486
- statusCode = this.statusCode,
487
- errorFlag = false,
488
- filter = this.getFilter('getRecentLikedMedia');
489
-
490
- if (typeof args == 'undefined' || args.length === 0) {
491
- noArgument = true;
492
- } else {
493
- if ('success' in args) {
494
- successFlag = true;
495
- }
496
- if ('error' in args) {
497
- errorFlag = true;
498
- }
499
- if( 'statusCode' in args ){
500
- statusCode = args['statusCode'];
501
- }
502
- }
503
-
504
-
505
- jQuery.ajax({
506
- type: 'POST',
507
- dataType: 'jsonp',
508
- url: 'https://api.instagram.com/v1/users/self/media/liked?access_token=' + getAccessToken(),
509
- success: function(response) {
510
- if (successFlag) {
511
- if (typeof args.success == 'object' && args.success.length == 2) {
512
- if (typeof window[args.success[0]] != 'undefined') {
513
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
514
- if (filter) {
515
- response = filter(response,instagram.filterArguments);
516
- }
517
- window[args.success[0]][args.success[1]](response);
518
- }
519
- }
520
- } else if (typeof args.success == 'string') {
521
- if (typeof window[args.success] == 'function') {
522
- if (filter) {
523
- response = filter(response,instagram.filterArguments);
524
- }
525
- window[args.success](response);
526
- }
527
- } else if (typeof args.success == 'function') {
528
- if (filter) {
529
- response = filter(response,instagram.filterArguments);
530
- }
531
- args.success(response);
532
- }
533
- }
534
- },
535
- error: function(response) {
536
- if (errorFlag) {
537
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
538
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
539
- window[args['error'][0]][args['error'][1]](response);
540
- }
541
- } else if (typeof args['error'] == 'string') {
542
- if (typeof window[args['error']] == 'function') {
543
- window[args['error']](response);
544
- }
545
- } else if (typeof args['error'] == 'function') {
546
- args['error'](response);
547
- }
548
- }
549
- },
550
- statusCode : statusCode
551
-
552
- });
553
- }
554
-
555
-
556
-
557
- /**
558
- * Get the most recent media published by a user.
559
- * This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
560
- *
561
- *
562
- * @definition success_callback => which function to call in case of success
563
- * @definition error_callback => which function to call in case of error
564
- * @definition media_count => number of media to request
565
- * @definition min_id => Return media before this min_id.
566
- * @definition max_id => Return media after this max_id.
567
- * @definition statusCode => StatusCode object.
568
- *
569
- * @param args = {
570
- * success : 'success_callback',
571
- * error : 'error_callback',
572
- * statusCode : statusCode,
573
- * count : 'media_count',
574
- * min_id : 'min_id',
575
- * max_id : 'max_id',
576
- * args: arguments to be passed to filtering function
577
- * }
578
- *
579
- *
580
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
581
- * or you can pass as callback function an anonymous function
582
- *
583
- *
584
- * @return object of founded media
585
- */
586
- this.getUserRecentMedia = function(user_id, args) {
587
- var instagram = this,
588
- noArgument = false,
589
- successFlag = false,
590
- argFlag = false,
591
- //internal default object for statusCode handling
592
- statusCode = this.statusCode,
593
- errorFlag = false,
594
- filter = this.getFilter('getUserRecentMedia'),
595
- baseUrl = 'https://api.instagram.com/v1/users/' + user_id + '/media/recent/?access_token=' + getAccessToken();
596
- if (typeof args == 'undefined' || args.length === 0) {
597
- noArgument = true;
598
- } else {
599
- if ('success' in args) {
600
- successFlag = true;
601
- }
602
-
603
- if( 'statusCode' in args ){
604
- statusCode = args['statusCode'];
605
- }
606
-
607
- if ( 'args' in args ){
608
- argFlag = true;
609
- }else{
610
- args.args = {};
611
- }
612
-
613
- if ('error' in args) {
614
- errorFlag = true;
615
- }
616
-
617
- if ('count' in args) {
618
- args['count'] = parseInt(args['count']);
619
- if (!Number.isInteger(args['count']) || args['count'] <= 0) {
620
- args.count = 33;
621
- }
622
- } else {
623
- args.count = 33;
624
- }
625
-
626
- baseUrl += '&count=' + args.count;
627
-
628
- if ('min_id' in args) {
629
- baseUrl += '&min_id=' + args.min_id;
630
- }
631
-
632
- if ('max_id' in args) {
633
- baseUrl += '&max_id=' + args.max_id;
634
- }
635
- }
636
-
637
-
638
- jQuery.ajax({
639
- type: 'POST',
640
- dataType: 'jsonp',
641
- url: baseUrl,
642
- success: function(response) {
643
- if (successFlag) {
644
- if (typeof args.success == 'object' && args.success.length == 2) {
645
- if (typeof window[args.success[0]] != 'undefined') {
646
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
647
- if (filter) {
648
- response = filter(response,instagram.filterArguments, args.args);
649
- }
650
- window[args.success[0]][args.success[1]](response);
651
- }
652
- }
653
- } else if (typeof args.success == 'string') {
654
- if (typeof window[args.success] == 'function') {
655
- if (filter) {
656
- response = filter(response,instagram.filterArguments, args.args);
657
- }
658
- window[args.success](response);
659
- }
660
- } else if (typeof args.success == 'function') {
661
- if (filter) {
662
- response = filter(response,instagram.filterArguments, args.args);
663
- }
664
- args.success(response);
665
- }
666
- }
667
- },
668
- error: function(response) {
669
- if (errorFlag) {
670
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
671
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
672
- window[args['error'][0]][args['error'][1]](response);
673
- }
674
- } else if (typeof args['error'] == 'string') {
675
- if (typeof window[args['error']] == 'function') {
676
- window[args['error']](response);
677
- }
678
- } else if (typeof args['error'] == 'function') {
679
- args['error'](response);
680
- }
681
- }
682
- },
683
- statusCode: statusCode
684
-
685
- });
686
-
687
- }
688
-
689
-
690
-
691
- /**
692
- * Get the most recent media published by the owner of the access_token.
693
- *
694
- *
695
- * @definition success_callback => which function to call in case of success
696
- * @definition error_callback => which function to call in case of error
697
- * @definition media_count => number of media to request
698
- * @definition min_id => Return media before this min_id.
699
- * @definition max_id => Return media after this max_id.
700
- * @definition statusCode => StatusCode object.
701
- *
702
- * @param args = {
703
- * success : 'success_callback',
704
- * error : 'error_callback',
705
- * count : 'media_count',
706
- * min_id : 'min_id'
707
- * max_id : 'max_id'
708
- * statusCode : statusCode
709
- *
710
- * }
711
- *
712
- *
713
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
714
- * or you can pass as callback function an anonymous function
715
- *
716
- *
717
- * @return object of founded media
718
- */
719
- this.getSelfRecentMedia = function(args) {
720
- var instagram = this,
721
- noArgument = false,
722
- successFlag = false,
723
- statusCode = this.statusCode;
724
- errorFlag = false,
725
- filter = this.getFilter('getSelfRecentMedia'),
726
- baseUrl = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=' + getAccessToken();
727
-
728
- if (typeof args == 'undefined' || args.length === 0) {
729
- noArgument = true;
730
- } else {
731
- if ('success' in args) {
732
- successFlag = true;
733
- }
734
-
735
- if ('error' in args) {
736
- errorFlag = true;
737
- }
738
-
739
- if( 'statusCode' in args ){
740
- statusCode = args['statusCode'];
741
- }
742
-
743
- if ('count' in args) {
744
- args['count'] = parseInt(args['count']);
745
- if (!Number.isInteger(args['count']) || args['count'] <= 0) {
746
- args.count = 33;
747
- }
748
- } else {
749
- args.count = 33;
750
- }
751
-
752
- baseUrl += '&count=' + args.count;
753
-
754
- if ('min_id' in args) {
755
- baseUrl += '&min_id=' + args.min_id;
756
- }
757
-
758
- if ('max_id' in args) {
759
- baseUrl += '&max_id=' + args.max_id;
760
- }
761
- }
762
-
763
- jQuery.ajax({
764
- type: 'POST',
765
- dataType: 'jsonp',
766
- url: baseUrl,
767
- success: function(response) {
768
- if (successFlag) {
769
- if (typeof args.success == 'object' && args.success.length == 2) {
770
- if (typeof window[args.success[0]] != 'undefined') {
771
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
772
- if (filter) {
773
- response = filter(response,instagram.filterArguments);
774
- }
775
- window[args.success[0]][args.success[1]](response);
776
- }
777
- }
778
- } else if (typeof args.success == 'string') {
779
- if (typeof window[args.success] == 'function') {
780
- if (filter) {
781
- response = filter(response,instagram.filterArguments);
782
- }
783
- window[args.success](response);
784
- }
785
- } else if (typeof args.success == 'function') {
786
- if (filter) {
787
- response = filter(response,instagram.filterArguments);
788
- }
789
- args.success(response);
790
- }
791
- }
792
- },
793
- error: function(response) {
794
- if (errorFlag) {
795
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
796
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
797
- window[args['error'][0]][args['error'][1]](response);
798
- }
799
- } else if (typeof args['error'] == 'string') {
800
- if (typeof window[args['error']] == 'function') {
801
- window[args['error']](response);
802
- }
803
- } else if (typeof args['error'] == 'function') {
804
- args['error'](response);
805
- }
806
- }
807
- },
808
- statusCode : statusCode
809
-
810
- });
811
- }
812
-
813
-
814
-
815
- /**
816
- * Get information about a user.
817
- * This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
818
- *
819
- *
820
- * @definition success_callback => which function to call in case of success
821
- * @definition error_callback => which function to call in case of error
822
- * @definition statusCode => StatusCode object.
823
- *
824
- * @param args = {
825
- * success : 'success_callback',
826
- * error : 'error_callback'
827
- * statusCode : statusCode
828
- * }
829
- *
830
- *
831
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
832
- * or you can pass as callback function an anonymous function
833
- *
834
- *
835
- * @return object of founded info
836
- */
837
- this.getUserInfo = function(user_id, args) {
838
- var instagram = this,
839
- noArgument = false,
840
- successFlag = false,
841
- statusCode = this.statusCode,
842
- errorFlag = false,
843
- filter = this.getFilter('getUserInfo');
844
-
845
- if (typeof args == 'undefined' || args.length === 0) {
846
- noArgument = true;
847
- } else {
848
- if ('success' in args) {
849
- successFlag = true;
850
- }
851
-
852
- if ('error' in args) {
853
- errorFlag = true;
854
- }
855
-
856
- if( 'statusCode' in args ){
857
- statusCode = args['statusCode'];
858
- }
859
- }
860
- jQuery.ajax({
861
- type: 'POST',
862
- dataType: 'jsonp',
863
- url: 'https://api.instagram.com/v1/users/' + user_id + '/?access_token=' + getAccessToken(),
864
- success: function(response) {
865
- if (successFlag) {
866
- if (typeof args.success == 'object' && args.success.length == 2) {
867
- if (typeof window[args.success[0]] != 'undefined') {
868
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
869
- if (filter) {
870
- response = filter(response,instagram.filterArguments);
871
- }
872
- window[args.success[0]][args.success[1]](response);
873
- }
874
- }
875
- } else if (typeof args.success == 'string') {
876
- if (typeof window[args.success] == 'function') {
877
- if (filter) {
878
- response = filter(response,instagram.filterArguments);
879
- }
880
- window[args.success](response);
881
- }
882
- } else if (typeof args.success == 'function') {
883
- if (filter) {
884
- response = filter(response,instagram.filterArguments);
885
- }
886
- args.success(response);
887
- }
888
- }
889
- },
890
- error: function(response) {
891
- if (errorFlag) {
892
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
893
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
894
- window[args['error'][0]][args['error'][1]](response);
895
- }
896
- } else if (typeof args['error'] == 'string') {
897
- if (typeof window[args['error']] == 'function') {
898
- window[args['error']](response);
899
- }
900
- } else if (typeof args['error'] == 'function') {
901
- args['error'](response);
902
- }
903
- }
904
- },
905
- statusCode : statusCode
906
-
907
- });
908
- }
909
-
910
-
911
-
912
- /**
913
- * Get information about the owner of the access_token.
914
- *
915
- *
916
- * @definition success_callback => which function to call in case of success
917
- * @definition error_callback => which function to call in case of error
918
- * @definition statusCode => StatusCode object.
919
- *
920
- * @param args = {
921
- * success : 'success_callback',
922
- * error : 'error_callback'
923
- * statusCode : statusCode
924
- * }
925
- *
926
- *
927
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
928
- * or you can pass as callback function an anonymous function
929
- *
930
- *
931
- * @return object of founded info
932
- */
933
- this.getSelfInfo = function(args) {
934
- var instagram = this,
935
- noArgument = false,
936
- successFlag = false,
937
- statusCode = this.statusCode,
938
- errorFlag = false,
939
- filter = this.getFilter('getSelfInfo');
940
- if (typeof args == 'undefined' || args.length === 0) {
941
- noArgument = true;
942
- } else {
943
- if ('success' in args) {
944
- successFlag = true;
945
- }
946
-
947
- if ('error' in args) {
948
- errorFlag = true;
949
- }
950
-
951
- if( 'statusCode' in args ){
952
- statusCode = args['statusCode'];
953
- }
954
- }
955
- jQuery.ajax({
956
- type: 'POST',
957
- dataType: 'jsonp',
958
- url: 'https://api.instagram.com/v1/users/self/?access_token=' + getAccessToken(),
959
- success: function(response) {
960
- if (successFlag) {
961
- if (typeof args.success == 'object' && args.success.length == 2) {
962
- if (typeof window[args.success[0]] != 'undefined') {
963
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
964
- if (filter) {
965
- response = filter(response,instagram.filterArguments);
966
- }
967
- window[args.success[0]][args.success[1]](response);
968
- }
969
- }
970
- } else if (typeof args.success == 'string') {
971
- if (typeof window[args.success] == 'function') {
972
- if (filter) {
973
- response = filter(response,instagram.filterArguments);
974
- }
975
- window[args.success](response);
976
- }
977
- } else if (typeof args.success == 'function') {
978
- if (filter) {
979
- response = filter(response,instagram.filterArguments);
980
- }
981
- args.success(response);
982
- }
983
- }
984
- },
985
- error: function(response) {
986
- if (errorFlag) {
987
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
988
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
989
- window[args['error'][0]][args['error'][1]](response);
990
- }
991
- } else if (typeof args['error'] == 'string') {
992
- if (typeof window[args['error']] == 'function') {
993
- window[args['error']](response);
994
- }
995
- } else if (typeof args['error'] == 'function') {
996
- args['error'](response);
997
- }
998
- }
999
- },
1000
- statusCode : statusCode
1001
-
1002
- });
1003
- }
1004
-
1005
-
1006
-
1007
- /**
1008
- * Get a list of recent comments on a media object.
1009
- * The public_content permission scope is required to get comments for a media
1010
- * that does not belong to the owner of the access_token.
1011
- *
1012
- * @media_id => id of the media which comments must be getted
1013
- * @definition success_callback => which function to call in case of success
1014
- * @definition error_callback => which function to call in case of error
1015
- * @definition statusCode => StatusCode object.
1016
- *
1017
- * @param args = {
1018
- * success : 'success_callback',
1019
- * error : 'error_callback'
1020
- * statusCode : statusCode
1021
- * }
1022
- *
1023
- *
1024
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1025
- * or you can pass as callback function an anonymous function
1026
- *
1027
- *
1028
- * @return object of founded comments
1029
- */
1030
- this.getRecentMediaComments = function(media_id, args) {
1031
- var instagram = this,
1032
- noArgument = false,
1033
- successFlag = false,
1034
- statusCode = this.statusCode,
1035
- errorFlag = false,
1036
- filter = this.getFilter('getRecentMediaComments');
1037
- if (typeof args == 'undefined' || args.length === 0) {
1038
- noArgument = true;
1039
- } else {
1040
- if ('success' in args) {
1041
- successFlag = true;
1042
- }
1043
-
1044
- if ('error' in args) {
1045
- errorFlag = true;
1046
- }
1047
-
1048
- if( 'statusCode' in args ){
1049
- statusCode = args['statusCode'];
1050
- }
1051
- }
1052
- jQuery.ajax({
1053
- type: 'POST',
1054
- dataType: 'jsonp',
1055
- url: 'https://api.instagram.com/v1/media/' + media_id + '/comments?access_token=' + getAccessToken(),
1056
- success: function(response) {
1057
- if (successFlag) {
1058
- if (typeof args.success == 'object' && args.success.length == 2) {
1059
- if (typeof window[args.success[0]] != 'undefined') {
1060
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
1061
- if (filter) {
1062
- response = filter(response,instagram.filterArguments);
1063
- }
1064
- window[args.success[0]][args.success[1]](response);
1065
- }
1066
- }
1067
- } else if (typeof args.success == 'string') {
1068
- if (typeof window[args.success] == 'function') {
1069
- if (filter) {
1070
- response = filter(response,instagram.filterArguments);
1071
- }
1072
- window[args.success](response);
1073
- }
1074
- } else if (typeof args.success == 'function') {
1075
- if (filter) {
1076
- response = filter(response,instagram.filterArguments);
1077
- }
1078
- args.success(response);
1079
- }
1080
- }
1081
- },
1082
- error: function(response) {
1083
- if (errorFlag) {
1084
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
1085
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1086
- window[args['error'][0]][args['error'][1]](response);
1087
- }
1088
- } else if (typeof args['error'] == 'string') {
1089
- if (typeof window[args['error']] == 'function') {
1090
- window[args['error']](response);
1091
- }
1092
- } else if (typeof args['error'] == 'function') {
1093
- args['error'](response);
1094
- }
1095
- }
1096
- },
1097
- statusCode : statusCode
1098
-
1099
- });
1100
- }
1101
-
1102
-
1103
-
1104
- /**
1105
- * Get a list of users who have liked this media.
1106
- *
1107
- * @media_id => id of the media which comments must be getted
1108
- * @definition success_callback => which function to call in case of success
1109
- * @definition error_callback => which function to call in case of error
1110
- * @definition statusCode => StatusCode object.
1111
- *
1112
- * @param args = {
1113
- * success : 'success_callback',
1114
- * error : 'error_callback'
1115
- * statusCode : statusCode
1116
- * }
1117
- *
1118
- *
1119
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1120
- * or you can pass as callback function an anonymous function
1121
- *
1122
- *
1123
- * @return object of founded comments
1124
- */
1125
- this.getRecentMediaLikes = function(media_id, args) {
1126
- var instagram = this,
1127
- noArgument = false,
1128
- successFlag = false,
1129
- statusCode = this.statusCode,
1130
- errorFlag = false,
1131
- filter = this.getFilter('getRecentMediaLikes');
1132
-
1133
- if (typeof args == 'undefined' || args.length === 0) {
1134
- noArgument = true;
1135
- } else {
1136
- if ('success' in args) {
1137
- successFlag = true;
1138
- }
1139
-
1140
- if ('error' in args) {
1141
- errorFlag = true;
1142
- }
1143
-
1144
- if( 'statusCode' in args ){
1145
- statusCode = args['statusCode'];
1146
- }
1147
- }
1148
- jQuery.ajax({
1149
- type: 'POST',
1150
- dataType: 'jsonp',
1151
- url: 'https://api.instagram.com/v1/media/' + media_id + '/likes?access_token=' + getAccessToken(),
1152
- success: function(response) {
1153
- if (successFlag) {
1154
- if (typeof args.success == 'object' && args.success.length == 2) {
1155
- if (typeof window[args.success[0]] != 'undefined') {
1156
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
1157
- if (filter) {
1158
- response = filter(response,instagram.filterArguments);
1159
- }
1160
- window[args.success[0]][args.success[1]](response);
1161
- }
1162
- }
1163
- } else if (typeof args.success == 'string') {
1164
- if (typeof window[args.success] == 'function') {
1165
- if (filter) {
1166
- response = filter(response,instagram.filterArguments);
1167
- }
1168
- window[args.success](response);
1169
- }
1170
- } else if (typeof args.success == 'function') {
1171
- if (filter) {
1172
- response = filter(response,instagram.filterArguments);
1173
- }
1174
- args.success(response);
1175
- }
1176
- }
1177
- },
1178
- error: function(response) {
1179
- if (errorFlag) {
1180
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
1181
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1182
- window[args['error'][0]][args['error'][1]](response);
1183
- }
1184
- } else if (typeof args['error'] == 'string') {
1185
- if (typeof window[args['error']] == 'function') {
1186
- window[args['error']](response);
1187
- }
1188
- } else if (typeof args['error'] == 'function') {
1189
- args['error'](response);
1190
- }
1191
- }
1192
- },
1193
- statusCode : statusCode
1194
-
1195
- });
1196
- }
1197
-
1198
-
1199
- /**
1200
- * make an ajax request based on url
1201
- *
1202
- *
1203
- * @definition success_callback => which function to call in case of success
1204
- * @definition error_callback => which function to call in case of error
1205
- * @definition statusCode => StatusCode object.
1206
- *
1207
- * @param args = {
1208
- * success : 'success_callback',
1209
- * error : 'error_callback',
1210
- * statusCode : statusCode,
1211
- * args.args : arguments to be passed to filter function
1212
- * }
1213
- *
1214
- *
1215
- * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1216
- * or you can pass as callback function an anonymous function
1217
- *
1218
- *
1219
- * @return object of founded media
1220
- */
1221
- this.requestByUrl = function(requestUrl, args) {
1222
- var instagram = this,
1223
- noArgument = false,
1224
- successFlag = false,
1225
- errorFlag = false,
1226
- argFlag = false,
1227
- statusCode = this.statusCode,
1228
- filter = this.getFilter('requestByUrl'),
1229
- urlParts,
1230
- urlPart;
1231
-
1232
- //changing access token to random one
1233
- urlParts = requestUrl.split('?')[1].split('&');
1234
- for (var i = 0; i < urlParts.length; i++) {
1235
- urlParts[i] = urlParts[i].split('=');
1236
- if (urlParts[i][0] == 'access_token') {
1237
- urlParts[i][1] = getAccessToken();
1238
- }
1239
- urlParts[i] = urlParts[i].join('=');
1240
- }
1241
- urlParts = urlParts.join('&');
1242
- requestUrl = requestUrl.split('?')[0] + '?' + urlParts;
1243
-
1244
-
1245
- if (typeof args == 'undefined' || args.length === 0) {
1246
- noArgument = true;
1247
- } else {
1248
- if ('success' in args) {
1249
- successFlag = true;
1250
- }
1251
-
1252
- if ( 'args' in args ){
1253
- argFlag = true;
1254
- }else{
1255
- args.args = {};
1256
- }
1257
-
1258
-
1259
- if ('error' in args) {
1260
- errorFlag = true;
1261
- }
1262
-
1263
- if( 'statusCode' in args ){
1264
- statusCode = args['statusCode'];
1265
- }
1266
- }
1267
-
1268
-
1269
- jQuery.ajax({
1270
- type: 'POST',
1271
- dataType: 'jsonp',
1272
- url: requestUrl,
1273
- success: function(response) {
1274
- if (successFlag) {
1275
- if (typeof args.success == 'object' && args.success.length == 2) {
1276
- if (typeof window[args.success[0]] != 'undefined') {
1277
- if (typeof window[args.success[0]][args.success[1]] == 'function') {
1278
- if (filter) {
1279
- response = filter(response,instagram.filterArguments, args.args);
1280
- }
1281
- window[args.success[0]][args.success[1]](response);
1282
- }
1283
- }
1284
- } else if (typeof args.success == 'string') {
1285
- if (typeof window[args.success] == 'function') {
1286
- if (filter) {
1287
- response = filter(response,instagram.filterArguments, args.args);
1288
- }
1289
- window[args.success](response);
1290
- }
1291
- } else if (typeof args.success == 'function') {
1292
- if (filter) {
1293
- response = filter(response,instagram.filterArguments, args.args);
1294
- }
1295
- args.success(response);
1296
- }
1297
- }
1298
- },
1299
- error: function(response) {
1300
- if (errorFlag) {
1301
- if (typeof args['error'] == 'object' && args['error'].length == 2) {
1302
- if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1303
- window[args['error'][0]][args['error'][1]](response);
1304
- }
1305
- } else if (typeof args['error'] == 'string') {
1306
- if (typeof window[args['error']] == 'function') {
1307
- window[args['error']](response);
1308
- }
1309
- } else if (typeof args['error'] == 'function') {
1310
- args['error'](response);
1311
- }
1312
- }
1313
- },
1314
- statusCode : statusCode
1315
-
1316
- });
1317
-
1318
- }
 
 
 
 
1319
  }
1320
 
1321
 
1322
 
1323
-
11
  *
12
  *
13
  * Methods:
14
+ * getSelfInfo = function( args ) : Get information about the owner of the access_token.
15
+ * searchForUsersByName = function( username, args ) : Get a list of users matching the query.
16
+ * searchForTagsByName = function(tagname, args) : Search for tags by name.
17
+ * getTagRecentMedia = function(tagname, args) : Gets recent media based on tagname
18
+ *
19
  */
20
 
21
 
25
  * @type {Object}
26
  */
27
  // var args = {
28
+ // access_tokens: ['227416602.145c5c2.302096fa9b3b4a8bbe0cee9341a6d7f5'],
29
+ // filters: [{
30
+ // where: 'getTagRecentMedia',
31
+ // what: function(r) {
32
+ // return r;
33
+ // },
34
  // }, {
35
+ // where: 'searchForUsersByName',
36
+ // what: 'bbb',
37
+ // }],
38
  // }
39
 
40
 
48
  * @param {Object} [args.filters[i] ] [ filter object which contain 'where' : 'what' pair ]
49
  * @param {String} [args.filters.filter[i].where] [name of function where filter must be applied]
50
  * @param {String or Array} [args.filters.filter[i].what] [name of filtering function,
51
+ * if function is in global scope then it should be name of the funtion
52
+ * else if function in method of some object then it should be an array
53
+ * ['parent_object_name','filtering_function_name']]
54
  */
55
  function WDIInstagram(args) {
56
 
57
+ this.access_tokens = [];
58
+ this.filters = [];
59
+ if (typeof args != 'undefined') {
60
+ if (typeof args.access_tokens != 'undefined') {
61
+ this.access_tokens = args.access_tokens;
62
+ }
63
+ if (typeof args.filters != 'undefined') {
64
+ this.filters = args.filters;
65
+ }
66
+ }
67
+
68
+
69
+ var _this = this;
70
+
71
+ /**
72
+ * Default object for handling status codes
73
+ * @type {Object}
74
+ */
75
+ this.statusCode = {
76
+ 429 : function(){
77
+ console.log(' 429: Too many requests try after one hour' );
78
+ },
79
+ }
80
+
81
+ /**
82
+ * gets filter function defined for specific method
83
+ * this function is internal function and cannot be called outside of this object
84
+ *
85
+ * @param {String} methodName [name of WDIInstagram method]
86
+ * @return {Function} [filtering function for {methodName}]
87
+ */
88
+ this.getFilter = function(methodName) {
89
+ var filters = _this.filters;
90
+ if (typeof filters == "undefined") {
91
+ return false;
92
+ }
93
+
94
+ for (var i = 0; i < filters.length; i++) {
95
+ if (filters[i].where == methodName) {
96
+
97
+ if (typeof filters[i].what == 'object' && filters[i].what.length == 2) {
98
+ if (typeof window[filters[i].what[0]] != 'undefined') {
99
+ if (typeof window[filters[i].what[0]][filters[i].what[1]] == 'function') {
100
+ return window[filters[i].what[0]][filters[i].what[1]];
101
+ }
102
+ }
103
+ } else if (typeof filters[i].what == 'string') {
104
+ if (typeof window[filters[i].what] == 'function') {
105
+ return window[filters[i].what];
106
+ }
107
+ } else if (typeof filters[i].what == 'function') {
108
+ return filters[i].what;
109
+ } else {
110
+ return false;
111
+ }
112
+ }
113
+ }
114
+ return false;
115
+ }
116
+
117
+ function getAccessToken() {
118
+ var access_tokens = _this.access_tokens,
119
+ index = parseInt(Math.random(0, 1) * access_tokens.length);
120
+ return access_tokens[index];
121
+ }
122
+
123
+ /**
124
+ * Adds access token to this.access_tokens array
125
+ * non string values are not allowed
126
+ * @param {String} token [Instagram API access token]
127
+ */
128
+ this.addToken = function(token) {
129
+ if (typeof token == 'string') {
130
+ _this.access_tokens.push(token);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Gets recent media based on tagname
136
+ *
137
+ *
138
+ * @definition success_callback => which function to call in case of success
139
+ * @definition error_callback => which function to call in case of error
140
+ * @definition media_count => number of media to request
141
+ * @definition min_tag_id => Return media before this min_tag_id.
142
+ * @definition max_tag_id => Return media after this max_tag_id.
143
+ * @definition statusCode => StatusCode object.
144
+ *
145
+ * @param tagname => A valid tag name without a leading #. (eg. snowy, nofilter)
146
+ * @param args = {
147
+ * success : 'success_callback',
148
+ * error : 'error_callback',
149
+ * statusCode : statusCode
150
+ * count : 'media_count',
151
+ * min_tag_id : 'min_tag_id',
152
+ * max_tag_id : 'max_tag_id',
153
+ * args : arguments to be passed to filtering function
154
+ * }
155
+ *
156
+ *
157
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
158
+ * or you can pass as callback function an anonymous function
159
+ *
160
+ *
161
+ * @return object of founded media
162
+ */
163
+ this.getTagRecentMedia = function(tagname, args) {
164
+ var instagram = this,
165
+ noArgument = false,
166
+ successFlag = false,
167
+ statusCode = this.statusCode;
168
+ errorFlag = false,
169
+ argFlag = false,
170
+ filter = this.getFilter('getTagRecentMedia');
171
+
172
+ baseUrl = 'https://api.instagram.com/v1/tags/' + tagname + '/media/recent?access_token=' + getAccessToken();
173
+
174
+
175
+ if (typeof args == 'undefined' || args.length === 0) {
176
+ noArgument = true;
177
+ } else {
178
+
179
+ if ('success' in args) {
180
+ successFlag = true;
181
+ }
182
+ if( 'statusCode' in args ){
183
+ statusCode = args['statusCode'];
184
+ }
185
+ if ('error' in args) {
186
+ errorFlag = true;
187
+ }
188
  //
189
+ if ( 'args' in args ){
190
+ argFlag = true;
191
+ }else{
192
+ args.args = {};
193
+ }
194
  //
195
+ if ('count' in args) {
196
+ args['count'] = parseInt(args['count']);
197
+ if (!Number.isInteger(args['count']) || args['count'] <= 0) {
198
+ args.count = 33;
199
+ }
200
+ } else {
201
+ args.count = 33;
202
+ }
203
+
204
+ baseUrl += '&count=' + args.count;
205
+
206
+ if ('min_tag_id' in args) {
207
+ baseUrl += '&min_tag_id=' + args.min_tag_id;
208
+ }
209
+
210
+ if ('max_tag_id' in args) {
211
+ baseUrl += '&max_tag_id=' + args.max_tag_id;
212
+ }
213
+ }
214
+
215
+ jQuery.ajax({
216
+ type: 'POST',
217
+ url: baseUrl,
218
+ dataType: 'jsonp',
219
+ success: function(response) {
220
+ if (successFlag) {
221
+ if (typeof args.success == 'object' && args.success.length == 2) {
222
+ if (typeof window[args.success[0]] != 'undefined') {
223
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
224
+ if (filter) {
225
+ response = filter(response,instagram.filterArguments, args.args);
226
+ }
227
+ window[args.success[0]][args.success[1]](response);
228
+ }
229
+ }
230
+
231
+ } else if (typeof args.success == 'string') {
232
+ if (typeof window[args.success] == 'function') {
233
+ if (filter) {
234
+ response = filter(response,instagram.filterArguments, args.args);
235
+ }
236
+ window[args.success](response);
237
+ }
238
+ } else if (typeof args.success == 'function') {
239
+ if (filter) {
240
+ response = filter(response,instagram.filterArguments, args.args);
241
+ }
242
+ args.success(response);
243
+ }
244
+ }
245
+ },
246
+ error: function(response) {
247
+ if (errorFlag) {
248
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
249
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
250
+ window[args['error'][0]][args['error'][1]](response);
251
+ }
252
+ } else if (typeof args['error'] == 'string') {
253
+ if (typeof window[args['error']] == 'function') {
254
+ window[args['error']](response);
255
+ }
256
+ } else if (typeof args['error'] == 'function') {
257
+ args['error'](response);
258
+ }
259
+ }
260
+ },
261
+ statusCode : statusCode
262
+ });
263
+
264
+ }
265
+
266
+
267
+ /**
268
+ * Search for tags by name.
269
+ *
270
+ *
271
+ * @definition success_callback => which function to call in case of success
272
+ * @definition error_callback => which function to call in case of error
273
+ * @definition statusCode => StatusCode object.
274
+ *
275
+ * @param tagname => A valid tag name without a leading #. (eg. snowy, nofilter)
276
+ * @param args = {
277
+ * success: 'success_callback',
278
+ * error: 'error_callback',
279
+ * statusCode : statusCode,
280
+ * }
281
+ *
282
+ *
283
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
284
+ * or you can pass as callback function an anonymous function
285
+ *
286
+ *
287
+ * @return object of founded media
288
+ */
289
+
290
+ this.searchForTagsByName = function(tagname, args) {
291
+ var instagram = this,
292
+ noArgument = false,
293
+ successFlag = false,
294
+ statusCode = this.statusCode;
295
+ errorFlag = false;
296
+ filter = this.getFilter('searchForTagsByName');
297
+
298
+ if (typeof args == 'undefined' || args.length === 0) {
299
+ noArgument = true;
300
+ } else {
301
+ if ('success' in args) {
302
+ successFlag = true;
303
+ }
304
+ if ('error' in args) {
305
+ errorFlag = true;
306
+ }
307
+ if( 'statusCode' in args ){
308
+ statusCode = args['statusCode'];
309
+ }
310
+ }
311
+
312
+
313
+ jQuery.ajax({
314
+ type: 'POST',
315
+ url: 'https://api.instagram.com/v1/tags/search?q=' + tagname + '&access_token=' + getAccessToken(),
316
+ dataType: 'jsonp',
317
+ success: function(response) {
318
+ if (successFlag) {
319
+ if (typeof args.success == 'object' && args.success.length == 2) {
320
+ if (typeof window[args.success[0]] != 'undefined') {
321
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
322
+ if (filter) {
323
+ response = filter(response,instagram.filterArguments);
324
+ }
325
+ window[args.success[0]][args.success[1]](response);
326
+ }
327
+ }
328
+ } else if (typeof args.success == 'string') {
329
+ if (typeof window[args.success] == 'function') {
330
+ if (filter) {
331
+ response = filter(response,instagram.filterArguments);
332
+ }
333
+ window[args.success](response);
334
+ }
335
+ } else if (typeof args.success == 'function') {
336
+ if (filter) {
337
+ response = filter(response,instagram.filterArguments);
338
+ }
339
+ args.success(response);
340
+ }
341
+ }
342
+ },
343
+ error: function(response) {
344
+ if (errorFlag) {
345
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
346
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
347
+ window[args['error'][0]][args['error'][1]](response);
348
+ }
349
+ } else if (typeof args['error'] == 'string') {
350
+ if (typeof window[args['error']] == 'function') {
351
+ window[args['error']](response);
352
+ }
353
+ } else if (typeof args['error'] == 'function') {
354
+ args['error'](response);
355
+ }
356
+ }
357
+ },
358
+ statusCode: statusCode
359
+ });
360
+ }
361
+
362
+
363
+
364
+ /**
365
+ * Get a list of users matching the query.
366
+ *
367
+ *
368
+ * @definition success_callback => which function to call in case of success
369
+ * @definition error_callback => which function to call in case of error
370
+ * @definition statusCode => StatusCode object.
371
+ *
372
+ * @param username
373
+ * @param args = {
374
+ * success: 'success_callback',
375
+ * error: 'error_callback',
376
+ * statusCode : statusCode
377
+ * }
378
+ *
379
+ *
380
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
381
+ * or you can pass as callback function an anonymous function
382
+ *
383
+ *
384
+ * @return object of founded users
385
+ */
386
+ this.searchForUsersByName = function(username, args) {
387
+ var instagram = this,
388
+ noArgument = false,
389
+ successFlag = false,
390
+ statusCode = this.statusCode,
391
+ errorFlag = false,
392
+ filter = this.getFilter('searchForUsersByName');
393
+
394
+ if (typeof args == 'undefined' || args.length === 0) {
395
+ noArgument = true;
396
+ } else {
397
+ if ('success' in args) {
398
+ successFlag = true;
399
+ }
400
+ if ('error' in args) {
401
+ errorFlag = true;
402
+ }
403
+ if( 'statusCode' in args ){
404
+ statusCode = args['statusCode'];
405
+ }
406
+ }
407
+
408
+
409
+ jQuery.ajax({
410
+ type: 'POST',
411
+ dataType: 'jsonp',
412
+ url: 'https://api.instagram.com/v1/users/search?q=' + username + '&access_token=' + getAccessToken(),
413
+ success: function(response) {
414
+ if (successFlag) {
415
+ if (typeof args.success == 'object' && args.success.length == 2) {
416
+ if (typeof window[args.success[0]] != 'undefined') {
417
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
418
+ if (filter) {
419
+ response = filter(response,instagram.filterArguments);
420
+ }
421
+ response.args = args;
422
+ window[args.success[0]][args.success[1]](response);
423
+ }
424
+ }
425
+ } else if (typeof args.success == 'string') {
426
+ if (typeof window[args.success] == 'function') {
427
+ if (filter) {
428
+ response = filter(response,instagram.filterArguments);
429
+ }
430
+ response.args = args;
431
+ window[args.success](response);
432
+ }
433
+ } else if (typeof args.success == 'function') {
434
+ if (filter) {
435
+ response = filter(response,instagram.filterArguments);
436
+ }
437
+ response.args = args;
438
+ args.success(response);
439
+ }
440
+ }
441
+ },
442
+ error: function(response) {
443
+ if (errorFlag) {
444
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
445
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
446
+ window[args['error'][0]][args['error'][1]](response);
447
+ }
448
+ } else if (typeof args['error'] == 'string') {
449
+ if (typeof window[args['error']] == 'function') {
450
+ window[args['error']](response);
451
+ }
452
+ } else if (typeof args['error'] == 'function') {
453
+ args['error'](response);
454
+ }
455
+ }
456
+ },
457
+ statusCode : this.statusCode
458
+
459
+ });
460
+ }
461
+
462
+
463
+
464
+ /**
465
+ * Get the list of recent media liked by the owner of the access_token.
466
+ *
467
+ *
468
+ * @definition success_callback => which function to call in case of success
469
+ * @definition error_callback => which function to call in case of error
470
+ * @definition statusCode => StatusCode object.
471
+ * @param args = {
472
+ * success: 'success_callback',
473
+ * error: 'error_callback',
474
+ * statusCode : statusCode
475
+ * }
476
+ *
477
+ *
478
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
479
+ * or you can pass as callback function an anonymous function
480
+ *
481
+ *
482
+ * @return object of founded media
483
+ */
484
+
485
+ this.getRecentLikedMedia = function(args) {
486
+ var instagram = this,
487
+ noArgument = false,
488
+ successFlag = false,
489
+ statusCode = this.statusCode,
490
+ errorFlag = false,
491
+ filter = this.getFilter('getRecentLikedMedia');
492
+
493
+ if (typeof args == 'undefined' || args.length === 0) {
494
+ noArgument = true;
495
+ } else {
496
+ if ('success' in args) {
497
+ successFlag = true;
498
+ }
499
+ if ('error' in args) {
500
+ errorFlag = true;
501
+ }
502
+ if( 'statusCode' in args ){
503
+ statusCode = args['statusCode'];
504
+ }
505
+ }
506
+
507
+
508
+ jQuery.ajax({
509
+ type: 'POST',
510
+ dataType: 'jsonp',
511
+ url: 'https://api.instagram.com/v1/users/self/media/liked?access_token=' + getAccessToken(),
512
+ success: function(response) {
513
+ if (successFlag) {
514
+ if (typeof args.success == 'object' && args.success.length == 2) {
515
+ if (typeof window[args.success[0]] != 'undefined') {
516
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
517
+ if (filter) {
518
+ response = filter(response,instagram.filterArguments);
519
+ }
520
+ window[args.success[0]][args.success[1]](response);
521
+ }
522
+ }
523
+ } else if (typeof args.success == 'string') {
524
+ if (typeof window[args.success] == 'function') {
525
+ if (filter) {
526
+ response = filter(response,instagram.filterArguments);
527
+ }
528
+ window[args.success](response);
529
+ }
530
+ } else if (typeof args.success == 'function') {
531
+ if (filter) {
532
+ response = filter(response,instagram.filterArguments);
533
+ }
534
+ args.success(response);
535
+ }
536
+ }
537
+ },
538
+ error: function(response) {
539
+ if (errorFlag) {
540
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
541
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
542
+ window[args['error'][0]][args['error'][1]](response);
543
+ }
544
+ } else if (typeof args['error'] == 'string') {
545
+ if (typeof window[args['error']] == 'function') {
546
+ window[args['error']](response);
547
+ }
548
+ } else if (typeof args['error'] == 'function') {
549
+ args['error'](response);
550
+ }
551
+ }
552
+ },
553
+ statusCode : statusCode
554
+
555
+ });
556
+ }
557
+
558
+
559
+
560
+ /**
561
+ * Get the most recent media published by a user.
562
+ * This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
563
+ *
564
+ *
565
+ * @definition success_callback => which function to call in case of success
566
+ * @definition error_callback => which function to call in case of error
567
+ * @definition media_count => number of media to request
568
+ * @definition min_id => Return media before this min_id.
569
+ * @definition max_id => Return media after this max_id.
570
+ * @definition statusCode => StatusCode object.
571
+ *
572
+ * @param args = {
573
+ * success : 'success_callback',
574
+ * error : 'error_callback',
575
+ * statusCode : statusCode,
576
+ * count : 'media_count',
577
+ * min_id : 'min_id',
578
+ * max_id : 'max_id',
579
+ * args: arguments to be passed to filtering function
580
+ * }
581
+ *
582
+ *
583
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
584
+ * or you can pass as callback function an anonymous function
585
+ *
586
+ *
587
+ * @return object of founded media
588
+ */
589
+ this.getUserRecentMedia = function(user_id, args) {
590
+ var instagram = this,
591
+ noArgument = false,
592
+ successFlag = false,
593
+ argFlag = false,
594
+ //internal default object for statusCode handling
595
+ statusCode = this.statusCode,
596
+ errorFlag = false,
597
+ filter = this.getFilter('getUserRecentMedia'),
598
+ baseUrl = 'https://api.instagram.com/v1/users/' + user_id + '/media/recent/?access_token=' + getAccessToken();
599
+ if (typeof args == 'undefined' || args.length === 0) {
600
+ noArgument = true;
601
+ } else {
602
+ if ('success' in args) {
603
+ successFlag = true;
604
+ }
605
+
606
+ if( 'statusCode' in args ){
607
+ statusCode = args['statusCode'];
608
+ }
609
+
610
+ if ( 'args' in args ){
611
+ argFlag = true;
612
+ }else{
613
+ args.args = {};
614
+ }
615
+
616
+ if ('error' in args) {
617
+ errorFlag = true;
618
+ }
619
+
620
+ if ('count' in args) {
621
+ args['count'] = parseInt(args['count']);
622
+ if (!Number.isInteger(args['count']) || args['count'] <= 0) {
623
+ args.count = 33;
624
+ }
625
+ } else {
626
+ args.count = 33;
627
+ }
628
+
629
+ baseUrl += '&count=' + args.count;
630
+
631
+ if ('min_id' in args) {
632
+ baseUrl += '&min_id=' + args.min_id;
633
+ }
634
+
635
+ if ('max_id' in args) {
636
+ baseUrl += '&max_id=' + args.max_id;
637
+ }
638
+ }
639
+
640
+
641
+ jQuery.ajax({
642
+ type: 'POST',
643
+ dataType: 'jsonp',
644
+ url: baseUrl,
645
+ success: function(response) {
646
+
647
+ if (successFlag) {
648
+ if (typeof args.success == 'object' && args.success.length == 2) {
649
+ if (typeof window[args.success[0]] != 'undefined') {
650
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
651
+ if (filter) {
652
+ response = filter(response,instagram.filterArguments, args.args);
653
+ }
654
+ window[args.success[0]][args.success[1]](response);
655
+ }
656
+ }
657
+ } else if (typeof args.success == 'string') {
658
+ if (typeof window[args.success] == 'function') {
659
+ if (filter) {
660
+ response = filter(response,instagram.filterArguments, args.args);
661
+ }
662
+ window[args.success](response);
663
+ }
664
+ } else if (typeof args.success == 'function') {
665
+ if (filter) {
666
+ response = filter(response,instagram.filterArguments, args.args);
667
+ }
668
+ args.success(response);
669
+ }
670
+ }
671
+ },
672
+ error: function(response) {
673
+ if (errorFlag) {
674
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
675
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
676
+ window[args['error'][0]][args['error'][1]](response);
677
+ }
678
+ } else if (typeof args['error'] == 'string') {
679
+ if (typeof window[args['error']] == 'function') {
680
+ window[args['error']](response);
681
+ }
682
+ } else if (typeof args['error'] == 'function') {
683
+ args['error'](response);
684
+ }
685
+ }
686
+ },
687
+ statusCode: statusCode
688
+
689
+ });
690
+
691
+ }
692
+
693
+
694
+
695
+ /**
696
+ * Get the most recent media published by the owner of the access_token.
697
+ *
698
+ *
699
+ * @definition success_callback => which function to call in case of success
700
+ * @definition error_callback => which function to call in case of error
701
+ * @definition media_count => number of media to request
702
+ * @definition min_id => Return media before this min_id.
703
+ * @definition max_id => Return media after this max_id.
704
+ * @definition statusCode => StatusCode object.
705
+ *
706
+ * @param args = {
707
+ * success : 'success_callback',
708
+ * error : 'error_callback',
709
+ * count : 'media_count',
710
+ * min_id : 'min_id'
711
+ * max_id : 'max_id'
712
+ * statusCode : statusCode
713
+ *
714
+ * }
715
+ *
716
+ *
717
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
718
+ * or you can pass as callback function an anonymous function
719
+ *
720
+ *
721
+ * @return object of founded media
722
+ */
723
+ this.getSelfRecentMedia = function(args) {
724
+ var instagram = this,
725
+ noArgument = false,
726
+ successFlag = false,
727
+ statusCode = this.statusCode;
728
+ errorFlag = false,
729
+ filter = this.getFilter('getSelfRecentMedia'),
730
+ baseUrl = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=' + getAccessToken();
731
+
732
+ if (typeof args == 'undefined' || args.length === 0) {
733
+ noArgument = true;
734
+ } else {
735
+ if ('success' in args) {
736
+ successFlag = true;
737
+ }
738
+
739
+ if ('error' in args) {
740
+ errorFlag = true;
741
+ }
742
+
743
+ if( 'statusCode' in args ){
744
+ statusCode = args['statusCode'];
745
+ }
746
+
747
+ if ('count' in args) {
748
+ args['count'] = parseInt(args['count']);
749
+ if (!Number.isInteger(args['count']) || args['count'] <= 0) {
750
+ args.count = 33;
751
+ }
752
+ } else {
753
+ args.count = 33;
754
+ }
755
+
756
+ baseUrl += '&count=' + args.count;
757
+
758
+ if ('min_id' in args) {
759
+ baseUrl += '&min_id=' + args.min_id;
760
+ }
761
+
762
+ if ('max_id' in args) {
763
+ baseUrl += '&max_id=' + args.max_id;
764
+ }
765
+ }
766
+
767
+ jQuery.ajax({
768
+ type: 'POST',
769
+ dataType: 'jsonp',
770
+ url: baseUrl,
771
+ success: function(response) {
772
+ if (successFlag) {
773
+ if (typeof args.success == 'object' && args.success.length == 2) {
774
+ if (typeof window[args.success[0]] != 'undefined') {
775
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
776
+ if (filter) {
777
+ response = filter(response,instagram.filterArguments);
778
+ }
779
+ window[args.success[0]][args.success[1]](response);
780
+ }
781
+ }
782
+ } else if (typeof args.success == 'string') {
783
+ if (typeof window[args.success] == 'function') {
784
+ if (filter) {
785
+ response = filter(response,instagram.filterArguments);
786
+ }
787
+ window[args.success](response);
788
+ }
789
+ } else if (typeof args.success == 'function') {
790
+ if (filter) {
791
+ response = filter(response,instagram.filterArguments);
792
+ }
793
+ args.success(response);
794
+ }
795
+ }
796
+ },
797
+ error: function(response) {
798
+ if (errorFlag) {
799
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
800
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
801
+ window[args['error'][0]][args['error'][1]](response);
802
+ }
803
+ } else if (typeof args['error'] == 'string') {
804
+ if (typeof window[args['error']] == 'function') {
805
+ window[args['error']](response);
806
+ }
807
+ } else if (typeof args['error'] == 'function') {
808
+ args['error'](response);
809
+ }
810
+ }
811
+ },
812
+ statusCode : statusCode
813
+
814
+ });
815
+ }
816
+
817
+
818
+
819
+ /**
820
+ * Get information about a user.
821
+ * This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
822
+ *
823
+ *
824
+ * @definition success_callback => which function to call in case of success
825
+ * @definition error_callback => which function to call in case of error
826
+ * @definition statusCode => StatusCode object.
827
+ *
828
+ * @param args = {
829
+ * success : 'success_callback',
830
+ * error : 'error_callback'
831
+ * statusCode : statusCode
832
+ * }
833
+ *
834
+ *
835
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
836
+ * or you can pass as callback function an anonymous function
837
+ *
838
+ *
839
+ * @return object of founded info
840
+ */
841
+ this.getUserInfo = function(user_id, args) {
842
+ var instagram = this,
843
+ noArgument = false,
844
+ successFlag = false,
845
+ statusCode = this.statusCode,
846
+ errorFlag = false,
847
+ filter = this.getFilter('getUserInfo');
848
+
849
+ if (typeof args == 'undefined' || args.length === 0) {
850
+ noArgument = true;
851
+ } else {
852
+ if ('success' in args) {
853
+ successFlag = true;
854
+ }
855
+
856
+ if ('error' in args) {
857
+ errorFlag = true;
858
+ }
859
+
860
+ if( 'statusCode' in args ){
861
+ statusCode = args['statusCode'];
862
+ }
863
+ }
864
+ jQuery.ajax({
865
+ type: 'POST',
866
+ dataType: 'jsonp',
867
+ url: 'https://api.instagram.com/v1/users/' + user_id + '/?access_token=' + getAccessToken(),
868
+ success: function(response) {
869
+ if (successFlag) {
870
+ if (typeof args.success == 'object' && args.success.length == 2) {
871
+ if (typeof window[args.success[0]] != 'undefined') {
872
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
873
+ if (filter) {
874
+ response = filter(response,instagram.filterArguments);
875
+ }
876
+ window[args.success[0]][args.success[1]](response);
877
+ }
878
+ }
879
+ } else if (typeof args.success == 'string') {
880
+ if (typeof window[args.success] == 'function') {
881
+ if (filter) {
882
+ response = filter(response,instagram.filterArguments);
883
+ }
884
+ window[args.success](response);
885
+ }
886
+ } else if (typeof args.success == 'function') {
887
+ if (filter) {
888
+ response = filter(response,instagram.filterArguments);
889
+ }
890
+ args.success(response);
891
+ }
892
+ }
893
+ },
894
+ error: function(response) {
895
+ if (errorFlag) {
896
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
897
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
898
+ window[args['error'][0]][args['error'][1]](response);
899
+ }
900
+ } else if (typeof args['error'] == 'string') {
901
+ if (typeof window[args['error']] == 'function') {
902
+ window[args['error']](response);
903
+ }
904
+ } else if (typeof args['error'] == 'function') {
905
+ args['error'](response);
906
+ }
907
+ }
908
+ },
909
+ statusCode : statusCode
910
+
911
+ });
912
+ }
913
+
914
+
915
+
916
+ /**
917
+ * Get information about the owner of the access_token.
918
+ *
919
+ *
920
+ * @definition success_callback => which function to call in case of success
921
+ * @definition error_callback => which function to call in case of error
922
+ * @definition statusCode => StatusCode object.
923
+ *
924
+ * @param args = {
925
+ * success : 'success_callback',
926
+ * error : 'error_callback'
927
+ * statusCode : statusCode
928
+ * }
929
+ *
930
+ *
931
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
932
+ * or you can pass as callback function an anonymous function
933
+ *
934
+ *
935
+ * @return object of founded info
936
+ */
937
+ this.getSelfInfo = function(args) {
938
+ var instagram = this,
939
+ noArgument = false,
940
+ successFlag = false,
941
+ statusCode = this.statusCode,
942
+ errorFlag = false,
943
+ filter = this.getFilter('getSelfInfo');
944
+ if (typeof args == 'undefined' || args.length === 0) {
945
+ noArgument = true;
946
+ } else {
947
+ if ('success' in args) {
948
+ successFlag = true;
949
+ }
950
+
951
+ if ('error' in args) {
952
+ errorFlag = true;
953
+ }
954
+
955
+ if( 'statusCode' in args ){
956
+ statusCode = args['statusCode'];
957
+ }
958
+ }
959
+ jQuery.ajax({
960
+ type: 'POST',
961
+ dataType: 'jsonp',
962
+ url: 'https://api.instagram.com/v1/users/self/?access_token=' + getAccessToken(),
963
+ success: function(response) {
964
+ if (successFlag) {
965
+ if (typeof args.success == 'object' && args.success.length == 2) {
966
+ if (typeof window[args.success[0]] != 'undefined') {
967
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
968
+ if (filter) {
969
+ response = filter(response,instagram.filterArguments);
970
+ }
971
+ window[args.success[0]][args.success[1]](response);
972
+ }
973
+ }
974
+ } else if (typeof args.success == 'string') {
975
+ if (typeof window[args.success] == 'function') {
976
+ if (filter) {
977
+ response = filter(response,instagram.filterArguments);
978
+ }
979
+ window[args.success](response);
980
+ }
981
+ } else if (typeof args.success == 'function') {
982
+ if (filter) {
983
+ response = filter(response,instagram.filterArguments);
984
+ }
985
+ args.success(response);
986
+ }
987
+ }
988
+ },
989
+ error: function(response) {
990
+ if (errorFlag) {
991
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
992
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
993
+ window[args['error'][0]][args['error'][1]](response);
994
+ }
995
+ } else if (typeof args['error'] == 'string') {
996
+ if (typeof window[args['error']] == 'function') {
997
+ window[args['error']](response);
998
+ }
999
+ } else if (typeof args['error'] == 'function') {
1000
+ args['error'](response);
1001
+ }
1002
+ }
1003
+ },
1004
+ statusCode : statusCode
1005
+
1006
+ });
1007
+ }
1008
+
1009
+
1010
+
1011
+ /**
1012
+ * Get a list of recent comments on a media object.
1013
+ * The public_content permission scope is required to get comments for a media
1014
+ * that does not belong to the owner of the access_token.
1015
+ *
1016
+ * @media_id => id of the media which comments must be getted
1017
+ * @definition success_callback => which function to call in case of success
1018
+ * @definition error_callback => which function to call in case of error
1019
+ * @definition statusCode => StatusCode object.
1020
+ *
1021
+ * @param args = {
1022
+ * success : 'success_callback',
1023
+ * error : 'error_callback'
1024
+ * statusCode : statusCode
1025
+ * }
1026
+ *
1027
+ *
1028
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1029
+ * or you can pass as callback function an anonymous function
1030
+ *
1031
+ *
1032
+ * @return object of founded comments
1033
+ */
1034
+ this.getRecentMediaComments = function(media_id, args) {
1035
+ var instagram = this,
1036
+ noArgument = false,
1037
+ successFlag = false,
1038
+ statusCode = this.statusCode,
1039
+ errorFlag = false,
1040
+ filter = this.getFilter('getRecentMediaComments');
1041
+ if (typeof args == 'undefined' || args.length === 0) {
1042
+ noArgument = true;
1043
+ } else {
1044
+ if ('success' in args) {
1045
+ successFlag = true;
1046
+ }
1047
+
1048
+ if ('error' in args) {
1049
+ errorFlag = true;
1050
+ }
1051
+
1052
+ if( 'statusCode' in args ){
1053
+ statusCode = args['statusCode'];
1054
+ }
1055
+ }
1056
+ jQuery.ajax({
1057
+ type: 'POST',
1058
+ dataType: 'jsonp',
1059
+ url: 'https://api.instagram.com/v1/media/' + media_id + '/comments?access_token=' + getAccessToken(),
1060
+ success: function(response) {
1061
+ if (successFlag) {
1062
+ if (typeof args.success == 'object' && args.success.length == 2) {
1063
+ if (typeof window[args.success[0]] != 'undefined') {
1064
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
1065
+ if (filter) {
1066
+ response = filter(response,instagram.filterArguments);
1067
+ }
1068
+ window[args.success[0]][args.success[1]](response);
1069
+ }
1070
+ }
1071
+ } else if (typeof args.success == 'string') {
1072
+ if (typeof window[args.success] == 'function') {
1073
+ if (filter) {
1074
+ response = filter(response,instagram.filterArguments);
1075
+ }
1076
+ window[args.success](response);
1077
+ }
1078
+ } else if (typeof args.success == 'function') {
1079
+ if (filter) {
1080
+ response = filter(response,instagram.filterArguments);
1081
+ }
1082
+ args.success(response);
1083
+ }
1084
+ }
1085
+ },
1086
+ error: function(response) {
1087
+ if (errorFlag) {
1088
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
1089
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1090
+ window[args['error'][0]][args['error'][1]](response);
1091
+ }
1092
+ } else if (typeof args['error'] == 'string') {
1093
+ if (typeof window[args['error']] == 'function') {
1094
+ window[args['error']](response);
1095
+ }
1096
+ } else if (typeof args['error'] == 'function') {
1097
+ args['error'](response);
1098
+ }
1099
+ }
1100
+ },
1101
+ statusCode : statusCode
1102
+
1103
+ });
1104
+ }
1105
+
1106
+
1107
+
1108
+ /**
1109
+ * Get a list of users who have liked this media.
1110
+ *
1111
+ * @media_id => id of the media which comments must be getted
1112
+ * @definition success_callback => which function to call in case of success
1113
+ * @definition error_callback => which function to call in case of error
1114
+ * @definition statusCode => StatusCode object.
1115
+ *
1116
+ * @param args = {
1117
+ * success : 'success_callback',
1118
+ * error : 'error_callback'
1119
+ * statusCode : statusCode
1120
+ * }
1121
+ *
1122
+ *
1123
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1124
+ * or you can pass as callback function an anonymous function
1125
+ *
1126
+ *
1127
+ * @return object of founded comments
1128
+ */
1129
+ this.getRecentMediaLikes = function(media_id, args) {
1130
+ var instagram = this,
1131
+ noArgument = false,
1132
+ successFlag = false,
1133
+ statusCode = this.statusCode,
1134
+ errorFlag = false,
1135
+ filter = this.getFilter('getRecentMediaLikes');
1136
+
1137
+ if (typeof args == 'undefined' || args.length === 0) {
1138
+ noArgument = true;
1139
+ } else {
1140
+ if ('success' in args) {
1141
+ successFlag = true;
1142
+ }
1143
+
1144
+ if ('error' in args) {
1145
+ errorFlag = true;
1146
+ }
1147
+
1148
+ if( 'statusCode' in args ){
1149
+ statusCode = args['statusCode'];
1150
+ }
1151
+ }
1152
+ jQuery.ajax({
1153
+ type: 'POST',
1154
+ dataType: 'jsonp',
1155
+ url: 'https://api.instagram.com/v1/media/' + media_id + '/likes?access_token=' + getAccessToken(),
1156
+ success: function(response) {
1157
+ if (successFlag) {
1158
+ if (typeof args.success == 'object' && args.success.length == 2) {
1159
+ if (typeof window[args.success[0]] != 'undefined') {
1160
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
1161
+ if (filter) {
1162
+ response = filter(response,instagram.filterArguments);
1163
+ }
1164
+ window[args.success[0]][args.success[1]](response);
1165
+ }
1166
+ }
1167
+ } else if (typeof args.success == 'string') {
1168
+ if (typeof window[args.success] == 'function') {
1169
+ if (filter) {
1170
+ response = filter(response,instagram.filterArguments);
1171
+ }
1172
+ window[args.success](response);
1173
+ }
1174
+ } else if (typeof args.success == 'function') {
1175
+ if (filter) {
1176
+ response = filter(response,instagram.filterArguments);
1177
+ }
1178
+ args.success(response);
1179
+ }
1180
+ }
1181
+ },
1182
+ error: function(response) {
1183
+ if (errorFlag) {
1184
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
1185
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1186
+ window[args['error'][0]][args['error'][1]](response);
1187
+ }
1188
+ } else if (typeof args['error'] == 'string') {
1189
+ if (typeof window[args['error']] == 'function') {
1190
+ window[args['error']](response);
1191
+ }
1192
+ } else if (typeof args['error'] == 'function') {
1193
+ args['error'](response);
1194
+ }
1195
+ }
1196
+ },
1197
+ statusCode : statusCode
1198
+
1199
+ });
1200
+ }
1201
+
1202
+
1203
+ /**
1204
+ * make an ajax request based on url
1205
+ *
1206
+ *
1207
+ * @definition success_callback => which function to call in case of success
1208
+ * @definition error_callback => which function to call in case of error
1209
+ * @definition statusCode => StatusCode object.
1210
+ *
1211
+ * @param args = {
1212
+ * success : 'success_callback',
1213
+ * error : 'error_callback',
1214
+ * statusCode : statusCode,
1215
+ * args.args : arguments to be passed to filter function
1216
+ * }
1217
+ *
1218
+ *
1219
+ * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1220
+ * or you can pass as callback function an anonymous function
1221
+ *
1222
+ *
1223
+ * @return object of founded media
1224
+ */
1225
+ this.requestByUrl = function(requestUrl, args) {
1226
+ var instagram = this,
1227
+ noArgument = false,
1228
+ successFlag = false,
1229
+ errorFlag = false,
1230
+ argFlag = false,
1231
+ statusCode = this.statusCode,
1232
+ filter = this.getFilter('requestByUrl'),
1233
+ urlParts,
1234
+ urlPart;
1235
+
1236
+ //changing access token to random one
1237
+ urlParts = requestUrl.split('?')[1].split('&');
1238
+ for (var i = 0; i < urlParts.length; i++) {
1239
+ urlParts[i] = urlParts[i].split('=');
1240
+ if (urlParts[i][0] == 'access_token') {
1241
+ urlParts[i][1] = getAccessToken();
1242
+ }
1243
+ urlParts[i] = urlParts[i].join('=');
1244
+ }
1245
+ urlParts = urlParts.join('&');
1246
+ requestUrl = requestUrl.split('?')[0] + '?' + urlParts;
1247
+
1248
+
1249
+ if (typeof args == 'undefined' || args.length === 0) {
1250
+ noArgument = true;
1251
+ } else {
1252
+ if ('success' in args) {
1253
+ successFlag = true;
1254
+ }
1255
+
1256
+ if ( 'args' in args ){
1257
+ argFlag = true;
1258
+ }else{
1259
+ args.args = {};
1260
+ }
1261
+
1262
+
1263
+ if ('error' in args) {
1264
+ errorFlag = true;
1265
+ }
1266
+
1267
+ if( 'statusCode' in args ){
1268
+ statusCode = args['statusCode'];
1269
+ }
1270
+ }
1271
+
1272
+
1273
+ jQuery.ajax({
1274
+ type: 'POST',
1275
+ dataType: 'jsonp',
1276
+ url: requestUrl,
1277
+ success: function(response) {
1278
+ if (successFlag) {
1279
+ if (typeof args.success == 'object' && args.success.length == 2) {
1280
+ if (typeof window[args.success[0]] != 'undefined') {
1281
+ if (typeof window[args.success[0]][args.success[1]] == 'function') {
1282
+ if (filter) {
1283
+ response = filter(response,instagram.filterArguments, args.args);
1284
+ }
1285
+ window[args.success[0]][args.success[1]](response);
1286
+ }
1287
+ }
1288
+ } else if (typeof args.success == 'string') {
1289
+ if (typeof window[args.success] == 'function') {
1290
+ if (filter) {
1291
+ response = filter(response,instagram.filterArguments, args.args);
1292
+ }
1293
+ window[args.success](response);
1294
+ }
1295
+ } else if (typeof args.success == 'function') {
1296
+ if (filter) {
1297
+ response = filter(response,instagram.filterArguments, args.args);
1298
+ }
1299
+ args.success(response);
1300
+ }
1301
+ }
1302
+ },
1303
+ error: function(response) {
1304
+ if (errorFlag) {
1305
+ if (typeof args['error'] == 'object' && args['error'].length == 2) {
1306
+ if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1307
+ window[args['error'][0]][args['error'][1]](response);
1308
+ }
1309
+ } else if (typeof args['error'] == 'string') {
1310
+ if (typeof window[args['error']] == 'function') {
1311
+ window[args['error']](response);
1312
+ }
1313
+ } else if (typeof args['error'] == 'function') {
1314
+ args['error'](response);
1315
+ }
1316
+ }
1317
+ },
1318
+ statusCode : statusCode
1319
+
1320
+ });
1321
+
1322
+ }
1323
  }
1324
 
1325
 
1326
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
4
  Tags: : custom instagram Feed, instagram, instagram account, instagram feed, instagram photos, instagram plugin, instagram posts, instagram stream, instagram wall, mobile instagram, responsive instagram, gallery, hashtag, images, photos, shortcode, widget ,Grid instagram view, instagram gallery, instagram images, instagram page, instagram plugin, instagram responsive, instagram touch, Instagram widgets, lightbox instagram, lightbox, feed
5
  Requires at least: 3.9
6
  Tested up to: 4.5
7
- Stable tag: 1.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -73,7 +73,7 @@ Upgrade to [Instagram Feed Pro](https://web-dorado.com/products/wordpress-instag
73
  * Infinite scroll for the feed (Similar to Instagram standard)
74
  * Instagram Comments display in Lightbox
75
  * Instagram Hashtag/ Instagram User account filtering options
76
- * Conditional Filters
77
 
78
  == Installation ==
79
 
@@ -99,14 +99,19 @@ After downloading the ZIP file of the Instagram Feed WD plugin,
99
 
100
  == Screenshots ==
101
 
102
- 1. WordPress Instagram Feed WD - Thumbnail layout
103
- 2. WordPress Instagram Feed WD - Image browser layout
104
- 3. WordPress Instagram Feed WD - Lightbox
105
- 4. WordPress Instagram Feed WD - Edit Instagram Feed
106
- 5. WordPress Instagram Feed WD - Theme Settings
107
 
108
  == Changelog ==
109
 
 
 
 
 
 
110
  = 1.1.1 =
111
  Fixed: Bug when duplicating feeds
112
 
4
  Tags: : custom instagram Feed, instagram, instagram account, instagram feed, instagram photos, instagram plugin, instagram posts, instagram stream, instagram wall, mobile instagram, responsive instagram, gallery, hashtag, images, photos, shortcode, widget ,Grid instagram view, instagram gallery, instagram images, instagram page, instagram plugin, instagram responsive, instagram touch, Instagram widgets, lightbox instagram, lightbox, feed
5
  Requires at least: 3.9
6
  Tested up to: 4.5
7
+ Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
73
  * Infinite scroll for the feed (Similar to Instagram standard)
74
  * Instagram Comments display in Lightbox
75
  * Instagram Hashtag/ Instagram User account filtering options
76
+ * Conditional Filters
77
 
78
  == Installation ==
79
 
99
 
100
  == Screenshots ==
101
 
102
+ 1. WordPress Instagram Feed WD - Thumbnail layout
103
+ 2. WordPress Instagram Feed WD - Image browser layout
104
+ 3. WordPress Instagram Feed WD - Lightbox
105
+ 4. WordPress Instagram Feed WD - Edit Instagram Feed
106
+ 5. WordPress Instagram Feed WD - Theme Settings
107
 
108
  == Changelog ==
109
 
110
+ = 1.1.2 =
111
+ Fixed: Bug when saving theme data to some MySQL 5.6 databases
112
+ Changed: Pagination of hashtag feeds restored
113
+ Changed: Check and get user id on frontend if empty for some unknown reason
114
+
115
  = 1.1.1 =
116
  Fixed: Bug when duplicating feeds
117
 
update/wdi_update.php CHANGED
@@ -76,6 +76,9 @@ function wdi_update_diff($new_v, $old_v = 0.0){
76
  );
77
  update_option('wdi_admin_notice', $admin_notices_option);
78
  }
 
 
 
79
 
80
 
81
 
76
  );
77
  update_option('wdi_admin_notice', $admin_notices_option);
78
  }
79
+ if(version_compare($old_v, "1.2", '<')){
80
+ $wpdb->query("ALTER TABLE " . $wpdb->prefix . WDI_THEME_TABLE . " convert to character set latin1 collate latin1_general_ci");
81
+ }
82
 
83
 
84
 
wd-instagram-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Instagram Feed WD
4
  Plugin URI: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
5
  Description: WD Instagram Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
- Version: 1.1.1
7
  Author: WebDorado
8
  Author URI: https://web-dorado.com
9
  License: GPLv2 or later
@@ -20,7 +20,7 @@ define("WDI_META", "_".WDI_VAR."_meta");
20
  //define("wdi",'wdi');
21
  define('WDI_FEED_TABLE','wdi_feeds');
22
  define('WDI_THEME_TABLE','wdi_themes');
23
- define('WDI_VERSION','1.1.1');
24
  define('WDI_IS_PRO','false');
25
 
26
 
3
  Plugin Name: Instagram Feed WD
4
  Plugin URI: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
5
  Description: WD Instagram Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
+ Version: 1.1.2
7
  Author: WebDorado
8
  Author URI: https://web-dorado.com
9
  License: GPLv2 or later
20
  //define("wdi",'wdi');
21
  define('WDI_FEED_TABLE','wdi_feeds');
22
  define('WDI_THEME_TABLE','wdi_themes');
23
+ define('WDI_VERSION','1.1.2');
24
  define('WDI_IS_PRO','false');
25
 
26