目的別!yammer REST APIまとめ ~Group編~
公式ドキュメントにこういうリクエスト送ればこういうことできるみたいなことは書いてあるのですが正直これだけだと不足していると思います。
そこで今回はこれまに調査したGroupに関連するAPIを備忘録も兼ねてまとめてみたいと思います。
※yammerのREST APIはHTTPのAuthorizationヘッダに設定したトークン(≠ユーザー)のコンテキストで実行されます。
偽装を使って別ユーザーのコンテキストで実行したい場合はyammer REST APIのユーザー偽装について - Jun's blogを参考にしてください。
Privateグループを作りたい
POST https://www.yammer.com/api/v1/groups.json?name=<グループ名>&private=<1 or 0 もしくは true or false> 201 Created { "type": "group", "id": xxx, "full_name": "xxx", "network_id": xxx, "name": "xxx", "description": null, "privacy": "private", "url": "xxx", "web_url": "xxx", "mugshot_url": "xxx", "mugshot_url_template": "xxx", "mugshot_id": null, "show_in_directory": "true", "office365_url": null, "created_at": "2014/12/25 06:20:46 +0000", "creator_type": "user", "creator_id": xxx, "state": "active", "stats": { "members": 1, "updates": 0, "last_message_id": null, "last_message_at": null } }
※private=1:Privateグループ = true
private=0:Publicグループ = false
既存グループのPrivateとPublicを切り替えたい
PUT https://www.yammer.com/api/v1/groups/<グループID>.json?private=<1 or 0 もしくは true or false> 200 OK
Privateグループ作成時に、"グループ一覧に公開する"を指定したい
POST https://www.yammer.com/api/v1/groups.json?name=<グループ名>&private=1&show_in_directory=<1 or 0 もしくは true or false> 201 Created
※show_in_directory=1:グループ一覧に公開する = true
show_in_directory=0:グループ一覧に公開しない = false
既存Privateグループの"グループ一覧に公開する"を切り替えたい
PUT https://www.yammer.com/api/v1/groups/<グループID>.json?show_in_directory=<1 or 0 もしくは true or false> 200 OK
グループに登録されているユーザーを取得したい
GET https://www.yammer.com/api/v1/users/in_group/<グループID>.json 200 OK { "users": [ { "type": "user", "id": xxx, "name": "xxx", "state": "active", "full_name": "xxx", "job_title": null, "network_id": xxx, "mugshot_url": "xxx", "mugshot_url_template": "xxx", "url": "xxx", "web_url": "xxx", "activated_at": "2013/12/02 05:04:51 +0000", "stats": { "following": 2, "followers": 3, "updates": 0 } }, { "type": "user", "id": yyy, "name": "yyy", "state": "active", "full_name": "yyy", "job_title": "", "network_id": xxx, "mugshot_url": "xxx", "mugshot_url_template": "xxx", "url": "yyy", "web_url": "yyy", "activated_at": "2014/05/19 06:16:53 +0000", "stats": { "following": 1, "followers": 0, "updates": 0 } } ], "more_available": false, "meta": { "followed_user_ids": [] } }
グループにTopicを紐づけたメッセージを投稿したい
POST https://www.yammer.com/api/v1/messages.json?body=<メッセージ>&group_id=<グループID>&topic1=<トピック名> 201 Created { "threaded_extended": {}, "messages": [ { "id": xxx, "sender_id": xxx, "replied_to_id": null, "created_at": "2014/12/05 01:47:24 +0000", "network_id": xxx, "message_type": "update", "sender_type": "user", "url": "xxx", "web_url": "xxx", "group_id": xxx, "body": { "parsed": "投稿します", "plain": "投稿します", "rich": "投稿します" }, "thread_id": xxx, "client_type": "xxx", "client_url": "xxx", "system_message": false, "direct_message": false, "chat_client_sequence": null, "content_excerpt": "投稿します", "language": null, "notified_user_ids": [], "privacy": "public", "attachments": [], "liked_by": { "count": 0, "names": [] }, "group_created_id": xxx } ], "references": [ { "type": "user", "id": xxx, "name": "xxx", "state": "active", "full_name": "xxx", "job_title": "xxx", "network_id": xxx, "mugshot_url": "xxx", "mugshot_url_template": "xxx", "url": "xxx", "web_url": "xxx", "activated_at": "2014/03/25 00:23:50 +0000", "stats": { "following": 24, "followers": 24, "updates": 0 } }, { "url": "xxx", "web_url": "xxx", "type": "thread", "id": xxx, "network_id": xxx, "thread_starter_id": xxx, "group_id": xxx, "topics": [ { "id": xxx, "type": "topic" } ], "privacy": "public", "direct_message": false, "has_attachments": false, "stats": { "updates": 0, "shares": 0, "first_reply_id": null, "first_reply_at": null, "latest_reply_id": xxx, "latest_reply_at": "2014/12/05 01:47:24 +0000" }, "invited_user_ids": [] }, { "type": "group", "id": xxx, "full_name": "xxx", "network_id": xxx, "name": "xxx", "description": null, "privacy": "public", "url": "xxx", "web_url": "xxx", "mugshot_url": "xxx", "mugshot_url_template": "xxx", "mugshot_id": null, "show_in_directory": "true", "office365_url": null, "created_at": "2014/12/05 01:31:31 +0000" }, { "type": "topic", "id": xxx, "name": "テストトピック", "normalized_name": "テストトピック", "permalink": "テストトピック", "url": "xxx", "web_url": "xxx" } ], "external_references": [], "meta": { "requested_poll_interval": 60, "last_seen_message_id": null, "current_user_id": xxx, "followed_references": [], "ymodules": [], "newest_message_details": null, "feed_name": "xxx", "feed_desc": "xxx", "direct_from_body": false } }
※Topicはtopic1からtopic20まで指定可能
まとめ
以上、これまでに調べたGroup関連のAPIでした。
これやりたいけど公式ドキュメントに載っていない!
どういうリクエスト投げればいいかわからない!!っていう人の参考になればと思います。