mixiã¢ããªã§RESTful APIã使ã
ä»ãããªããmixiã¢ããªã§RESTful APIã使ãããã¨ã«æ°ã¥ããããã§ãæ©é試ãã¦ã¿ã¾ããã
mixiã®ãããããã¼åããµã¤ãã«ããµã³ãã«ã³ã¼ããä»ãã¦è©³ãã説æããã¦ããã®ã§ããããåèã«ãã¦æ¸ãã¦ããã°åé¡ãªãããã§ãã
å®éã®ãªã¯ã¨ã¹ãã«ã¯ããConsumer Keyãã¨ãConsumer Secretãã使ãã2-legged OAuthã«ãã£ã¦é©åã«ç½²åãããå¿
è¦ãããã¾ãã
ãConsumer Keyãã¨ãConsumer Secretãã¯ãã¢ããªãã¨ã«å²ãå½ã¦ããã¦ãããmixiã¢ããªè¨å®ç»é¢ããã確èªãããã¨ãã§ãã¾ãã
注æããç¹ã¯ãxoauth_requestor_idãããªã¯ã¨ã¹ãã«ä»å ããå¿ è¦ãããã¨ãããã¨ã§ããå ¬å¼ãµã¤ãããå¼ç¨ã§ãã
RESTful APIã«ã¢ã¯ã»ã¹ããéã«ãxoauth_requestor_idãã©ã¡ã¼ã¿ã«ãã£ã¦ã誰ã®æ¨©éã§ã¢ã¯ã»ã¹ãè¡ãããæå®ãããã¨ãå¿ è¦ã«ãªãã¾ãããã©ã¡ã¼ã¿å¤ã¯ã対象ã¦ã¼ã¶ã®IDã¨ãªãã¾ãããã®ã¦ã¼ã¶IDã«ã¤ãã¦ããä¸å®æéå ã«Webãã©ã¦ã¶ã§å¯¾è±¡ã®mixiã¢ããªãèµ·åããã¦ã¼ã¶ãã®IDã®ã¿æå®ãããã¨ãå¯è½ã§ãã
対象ã¦ã¼ã¶ã対象ã®mixiã¢ããªãèµ·åãã¦ããªãããããã¯èµ·åããä¸å®æéãçµéããå¾ã«RESTful APIã«ã¢ã¯ã»ã¹ãè¡ã£ãéã«ã¯ãHTTPã¬ã¹ãã³ã¹ã³ã¼ãã¨ãã¦ã401 Unauthorizedããè¿å´ããã¾ãã
対象ã¦ã¼ã¶ã®IDãããªãã¡ã³ã³ããããéããã¦ãããopensocial_viewer_idããæå®ãããã¨ã«ãªãã¾ãã
ä¸è¨ã®ãããªã³ã¼ãã§åãããã¨ãåºæ¥ã¾ãããç½²åã«ã¯oauthã©ã¤ãã©ãªã使ãã¾ãã
require 'oauth' consumer = OAuth::Consumer.new(ãã¢ããªã®Consumer Keyã, ãã¢ããªã®Consumer Secretã, {:site => 'http://api.mixi-platform.com'}) end_point = 'http://api.mixi-platform.com/os/0.8' req = consumer.request(:get, end_point + '/people/@me/@self' + '?xoauth_requestor_id=' + opensocial_viewer_id) JSON.parse(req.body) # JSONãã¼ã¿ããªãã¸ã§ã¯ãå
å ¬å¼ã«ã¯Rubyã®ã³ã¼ãããªãã£ããããªã®ã§è¼ãã¦ããã¾ãã