Permalink
Browse files

tags search

  • Loading branch information...
1 parent e1140f5 commit 015d8f348cd95c91f5fdcd6ccb369f6d768aef25 @Swizec committed Mar 2, 2011
Showing with 32 additions and 1 deletion.
  1. +20 −0 index.js
  2. +12 −1 tests.js
View
20 index.js
@@ -9,6 +9,7 @@ function InstagramClient(client_id, client_secret) {
this.client_secret = client_secret;
this.media = new InstagramMediaClient(this);
+ this.tags = new InstagramTagsClient(this);
}
InstagramClient.prototype.fetch = function (options, callback) {
@@ -74,6 +75,25 @@ InstagramMediaClient.prototype.search = function (parameters, callback) {
});
}
+function InstagramTagsClient (parent) {
+ this.parent = parent;
+}
+
+InstagramTagsClient.prototype.search = function (query, callback) {
+ var options = {
+ path: '/v1/tags/search/?q='+query+'&client_id='+this.parent.client_id
+ }
+
+ this.parent.fetch(options, function (response) {
+ if (response['meta']['code'] == 200) {
+ callback(response['data'], null);
+ }else{
+ callback(response['meta'], response['meta']['code']);
+ }
+ });
+}
+
+
exports.createClient = function (client_id, client_secret) {
var instagram_client = new InstagramClient(client_id, client_secret);
View
13 tests.js
@@ -45,4 +45,15 @@ exports.testMediaSearch = function (test) {
}
do_it(0);
-};
+};
+
+exports.testTagsSearch = function (test) {
+ test.expect(2);
+
+ instagram.tags.search('snow', function (tags, error) {
+ test.ok((tags.length > 0));
+ test.equal(error, null, "Returned an error");
+
+ test.done();
+ });
+}

0 comments on commit 015d8f3

Please sign in to comment.