Skip to content

Instantly share code, notes, and snippets.

@ElemarJR
Created November 2, 2012 20:49
Show Gist options
  • Select an option

  • Save ElemarJR/4004225 to your computer and use it in GitHub Desktop.

Select an option

Save ElemarJR/4004225 to your computer and use it in GitHub Desktop.
define(['amplify'],
function (amplify) {
var
mentionsDecoder = function(
data,
status,
xhr,
success,
error) {
if (status === "success") {
success( data.results );
} else if ( status === "fail" || status === "error" ) {
error( data.message, data.status );
} else {
error( data.message , "fatal" );
}
},
init = function() {
amplify.request.define( "twitter-mentions", "ajax", {
url: "http://search.twitter.com/search.json",
dataType: "jsonp",
dataMap: function( parameters ) {
return {
q: "@" + parameters.user
};
},
decoder : mentionsDecoder
});
},
getMentions = function(callbacks, nick) {
amplify.request(
{
resourceId: "twitter-mentions",
data: { user: nick },
success: callbacks.success,
error: callbacks.error
});
};
init();
return {
getMentions : getMentions
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment