Wednesday, 1 October 2014

Access Yammer API by Angularjs


I can use yammer JS api to access yammer, but now i want to try to use pure angularjs.

I have spent whole day to implement it.

And now I found that, the enpoint from yammer api works fine with REST client. But not work with angularjs, which is real weird, I haven't figure this out.


----
This is the code I use:

$http.get("https://www.yammer.com/api/v1/messages.json", {
    headers: {
    "Authorization" : "Bearer " + $scope.auth_token
    }
}).success(function(ok) {
    console.log(ok);
}).error(function(error) {
    console.log(error);

} );

----
This is the request headers:














---------
But below request header is the expected format:




-----
After I change the endpoint as below, it works:

$http.get("https://api.yammer.com/api/v1/messages.json", {
    headers: {
    "Authorization" : "Bearer " + $scope.auth_token
    }
}).success(function(ok) {
    console.log(ok);
}).error(function(error) {
    console.log(error);

} );



-----
I have hacked the request from Yammer API, it actually sent requests to this api.yammer.com instead of www.yammer.com.

However, couple of days ago, when I was researching how to access yammer by JS, somebody mentioned this url, but yammer support team mentioned that, this url is not suggested.


-----
poor application with a poor api.....








No comments:

Post a comment