mixiã®APIãå人åãã«å ¬éãããã®ã§æ©é試ãã¦ã¿ã - ãã©ããã¤ã¹
mixiã®APIããã£ã¨ä¸è¬å ¬é
æ¨æ¥ãã¤ãã«mixiã®æä¾ããæ°ããGraphAPIããå人éçºè
åãã«å
¬éããã¾ããï¼
APIãå人åãã«éæ¾ããã®ã¯ãä»åãåãã¦ã®ãã¨ã§ãã
個人の方もmixi Graph APIがご利用可能になりました
æ°ããGraphAPIã¯ããã¤ã¹ããã©ããã¡ãã»ã¼ã¸ããã§ãã¯ãæ´æ°æ å ±ãå人æ å ±ããªã©ãªã©ãè²ã ã¨æã£ã¦ãã¦ãèªè¨¼èªå¯ãOAuth2.0ã使ç¨ãã¦ãããã¨ã£ã¦ã使ããããç°¡åã§ãã
mixi Graph API » 技術仕様 » API共通仕様
ã©ããªäºãåºæ¥ããã¨ãããã¨ã§ããããéã³ã§ãããã®ãã©ãä»ããã¤ã¹ãæ稿ã§ãããä»æ¥ã®ã«ããããã¤ã¹ãã¨ãããµã³ãã«ãä½ã£ã¦ã¿ã¾ããã®ã§ãèå³ããã人ã¯ä½¿ã£ã¦ã¿ã¦ä¸ããã
ã¨ãããã¨ã§ãå
·ä½çã«ã©ãããã°ã©ã ããã°ãããã解説ãã¦ã¿ããã¨æãã¾ãã
ããªããæ©éãã¤ã¹ã®APIãç¨ãã¦ãåçä»ããã¤ã¹ãæ稿ãã¦ã¿ã¾ãããï¼
ã½ã¼ã¹ã³ã¼ãã¯GitHubã«ä¸ãã¦ããã¾ããã
ã¡ãªã¿ã«ã³ã³ã·ã¥ã¼ããã¼ã¨ã³ã³ã·ã¥ã¼ãã·ã¼ã¯ã¬ããã¯å¤±å¹ããã¦ã¾ãã®ã§ããèªåã§æ¸ãå¤ãã¦ãå©ç¨ãã ãããConsumerKeyã¨Secretã®ç®¡çã¯å³éã«ï¼çµ¶å¯¾äººã«æãã¡ããã¡ã ãï¼
【GitHub】kyoro / mixi_graph_api_sample_photovoice
æè¿GoogleCodeããgithubã«ä¹ãæããã®ã ãã©ã便å©ã§ããã¼
ã¢ããªã®ç»é²ã¨ãConsumerKey / ConsumerSecretã®çºè¡
ã¾ãã¯SAPãã¼ã¿ã«ã§ã¢ããªãç»é²ãã¦ConsumerKeyã¨Secretãçºè¡ãã¦ãã ããã
ååã¯ã¯ã¬ã¸ããã«ã¼ãã®èªè¨¼ãªã©ãå¿
è¦ã§ãã
課éã¨ããããã§ã¯ãªããä¿¡é ¼æ§ã®æ
ä¿ã¨ããæå³ãããã§ããAPIã®å©ç¨ã¯ç¡æã
ã¢ããªã®ç»é²ã«ã¯ã¡ã¢ãã®ç¢ºèªãªã©ãè¦æ±ãããã®ã§ã説æã«å¾ã£ã¦ãã ããã
ç»é²ãçµããã¨ConsumerKeyã¨ConsumerSecretãçºè¡ããã¾ãã
ã¾ãããµã¼ãã¹ç»é²æã«è¨å®ãããªãã¤ã¬ã¯ãURLã¯ããã°ã©ã ã§ã使ç¨ããã®ã§
ãµã¼ãã¹è¨å®ã¨ããã°ã©ã ã®åä¸æ§ãä¿ã£ã¦ãã ããã
ãµã³ãã«ããã°ã©ã ãèµ°ããã¦ã¿ã
githubã«ä¸ãã¦ãããµã³ãã«ãèµ°ããã¦ã¿ã¾ãã
ã¾ããconstantsã«æ¸ããã¦ããCONSUMER_KEYã¨CONSUMER_SECRETãããã³REDIRECT_URIãèªåã®ãã®ã«æ¸ãæãã¾ãã
REDIRECT_URIã¯åå¨ããªããã®ã§ã大ä¸å¤«ã§ããé©å½ãªãã®ãè¨å®ãã¦ãã ããã
å¤æ´ã¯ããã ãã§OKã§ãã
ã§ã¯å®è¡ã
perl post.pl
ããã¨
Aauthorize request in this page : https://mixi.jp/connect_authorize.pl?client_id=07c440f6acc01d7ae8f3&response_type=code&scope=w_voice&display=pc Please input redirest url's 'code' parameter :
ãããªæãã§è¡¨ç¤ºãããã®ã§ã表示ãããURLã«ã¢ã¯ã»ã¹ãã¦ã¢ã¯ã»ã¹ãèªå¯ãã¦ãã ããã
ãã®å¾ããªãã¤ã¬ã¯ãããããã¼ã¸ã®URLã®æ«å°¾ã«ä»ãã¦ããcode=以ä¸ã®å¤ãã³ããããEnterãæ¼ãã¾ãã
done.ã¨è¡¨ç¤ºãããããèªåã®ãã¤ã¹ã®ãã¼ã¸ãè¦ã¦è¦ã¾ãããã
ãã®ããã«ç°¡åã«ç»åãæ稿ã§ãã¾ãã
ããã°ã©ã ã®è§£èª¬
ããã°ã©ã ã解説ãã¾ããã¨ãã£ã¦ãããããç°¡åã§ãã
ä»åã¯perlã§å®è£
ãã¾ããããã©ã®è¨èªããããªã«éãã¯ããã¾ããã
ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªãªã©ã使ãã¾ããã使ãã®ã¯LWPã ãã§ãï¼ç¬ï¼
my $auth_uri = URI->new("https://mixi.jp/connect_authorize.pl"); $auth_uri->query_form_hash( client_id => CONSUMER_KEY, response_type => 'code', scope => 'w_voice', display => 'pc', ); print "Aauthorize request in this page :\n"; print $auth_uri->as_string(); print "\n\nPlease input redirest url's 'code' parameter :\n";
èªå¯ç»é¢ã®URLãçæãã¾ãã
éçãªURLãªã®ã§ãCONSUMER_KEYãå¤æ´ããªãã®ã§ããã°aã¿ã°ã¨ãã§ãããã§ãã
my $ua = LWP::UserAgent->new; my $token_res = $ua->post('https://secure.mixi-platform.com/2/token',{ grant_type => "authorization_code", client_id => CONSUMER_KEY, client_secret => CONSUMER_SECRET, code => $code, redirect_uri => REDIRECT_URI, }); my $token_res_hash = JSON::decode_json($token_res->content); my $access_token = $token_res_hash->{access_token}; my $post_endpoint = sprintf("http://api.mixi-platform.com/2/voice/statuses/update?oauth_token=%s",$access_token); my $post_res = $ua->post( $post_endpoint, Content_Type => 'form-data', Content => { status => 'neko neko koneko', photo => [ "sample.jpg" ], } );
codeãåãåã£ãããã¢ã¯ã»ã¹ãã¼ã¯ã³ãåå¾ãã¾ãã
ã¬ã¹ãã³ã¹ã¯JSONã§è¿ã£ã¦ããã®ã§ããã³ã¼ããã¦æ ¼ç´ãã¾ãã
ãã¨ã¯APIã®ä»æ§éãã«ãContent-Typeãè¨å®ãã¦ããã©ã¡ã¼ã¿ãä»ãã¦POSTãã¾ãã
ãã£ãããã ãã§OKã§ãï¼
ä»ã«ãé¢ç½ãããªAPIãè²ã
ããã®ã§ããã²çããéãã§ã¿ã¦ãï¼