Sunday, November 24, 2013

Winamp, a threat, a petition, AngularJS and shit is about to get real

A few days ago, I made a threat that I will remove people from the CDO-ITG group page if they didn't sign a certain petition. I said that I was doing to remove every shit on this group who didn't sign the Winamp petition and I said that I will know who didn't sign. Everyone laughed. Not. fucking. anymore.

Change.org has an API that allows me get at all of the signatures in the Winamp petition. Although, Change.org's API isn't quite mature, it's usable and quite easy to use with AngularJS. Here is a snippet:

wapp.factory('changeOrgService', function($resource){

    var _changeOrg = {};
    
    _changeOrg.getSignatures = function(petitionId){
        var baseUrl = 'https://api.change.org/v1/petitions';
        return $resource(baseUrl + '/:id/signatures?api_key=' + winampPapp.api_key + "&callback=JSON_CALLBACK",{id: petitionId}, 
            { get: { method: 'JSONP', params: { page: 1} }});
    };

    _changeOrg.getPetitionId = function(url){
        var baseUrl = 'http://api.change.org/v1/petitions/get_id';
        return $resource(baseUrl, {},
            { get: {method: 'JSONP'}, params:{api_key: winampPapp.api_key, petition_url: url, callback: 'JSON_CALLBACK'}});
    };

    return _changeOrg;
});

That should be easy to figure since its only a pretty simple AngularJS factory that depends on the ngResource module to get at the data. Add underscore and then you can do something interesting with the petition signature data like figure out how many signed from the Philippines (26), how many are from the Cagayan de Oro (DO YOU WANT TO FUCKING KNOW?! DO YOU?).


Now, how about REALLY signing that petition before I really do something crazy like find out where you live.

No comments:

Post a Comment