partiea4のブログ -3ページ目

partiea4のブログ

ブログの説明を入力します。

■3.1■Making Yammer API Requests


The JavaScript API allows calls to be made against the Yammer REST API directly from the user’s browser. By default requests are made against the user’s canonical network.
(ブラウザから直接APIを叩けるという意味でよいのかしら?)


さて、次はどうしたものか…


ひとまず<script>タグ内に記載の通り下記の部分を追加し、

yam.request(
{ url: "/api/v1/messages/following"
, method: "GET"
, data: "foo=bar"
, success: function (msg) { alert("Data Saved: " + msg); }
, error: function (msg) { alert("Data Not Saved: " + msg); }
}
)


getLoginStatusの部分で呼び出ししてみる

yam.getLoginStatus( function(response) {
if (response.authResponse) {
// logged in and connected user, someone you know
alert('status:logged in');
yam.request();
}
else{
// no user session available, someone you don’t know
alert('status:NOT logged in');
yam.login();

}
});


期待はしていなかったが、特になにも起こらず。。。



partiea4のブログ-003_1Authentication01.png


firefoxのWEBコンソールで確認すると
yam.request is not a function @yammer.html:47
と、yam.requestは関数でないと怒られる。


このJsのAPIページの下の方の書き込みに同様の問い合わせがある。
Sebpiqさんと同じように書いても同様。
回答もないので、どうしたらよいものか…


Sebpiq

Hi !
Weird error ... I am doing :
<script src="https://assets.yammer.com/platform/yam.js"></script >
<script>
$(function(){
yam.config({appId: "bbwkjbwkbswks"}); # I signed-in and put my key instead
console.log(yam); # this is to check what's in there
yam.request(
{ url: “/api/v1/messages/following”
, method: “GET”
, data: “foo=bar”
, success: function (msg) { alert(“Data Saved: ” + msg); }
, error: function (msg) { alert(“Data Not Saved: ” + msg); }
});
});
</script>

And I am getting "yam.request is not a function" error from my console. What could be the problem ? config failed ?