<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ひろぽっぽれす &#187; API</title>
	<atom:link href="http://hiropo.co.uk/archives/category/api/feed" rel="self" type="application/rss+xml" />
	<link>http://hiropo.co.uk</link>
	<description>Web系エンジニアの適当なブログです。どうでも酔いものばかり作ってます。</description>
	<lastBuildDate>Mon, 12 Mar 2012 06:10:01 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>[mixiアプリ] 2ちゃんねるまとめサイトのRSSリーダーをつくってみた</title>
		<link>http://hiropo.co.uk/archives/289</link>
		<comments>http://hiropo.co.uk/archives/289#comments</comments>
		<pubDate>Sun, 23 Aug 2009 16:18:18 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=289</guid>
		<description><![CDATA[いつも２ちゃんねるまとめサイトの巡回をするのだが、mixiアプリでRSSリーダーつくったら面白いかもと思い、1時間程度でmixiアプリをつくってみた。 google Ajax APIを使ったので、めちゃめちゃ簡単にできた &#8230; <a href="http://hiropo.co.uk/archives/289">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>いつも２ちゃんねるまとめサイトの巡回をするのだが、mixiアプリでRSSリーダーつくったら面白いかもと思い、1時間程度でmixiアプリをつくってみた。<br />
google Ajax APIを使ったので、めちゃめちゃ簡単にできたお。</p>
<p><a href="http://platform001.mixi.jp/run_appli.pl?id=6869" target="_blank"><img src="http://hiropo.co.uk/wp-content/uploads/2009/08/e5908de7a7b0e69caae8a8ade5ae9a-1-300x162.jpg" alt="" title="e5908de7a7b0e69caae8a8ade5ae9a-1" width="300" height="162" class="aligncenter size-medium wp-image-290" /></a></p>
<p><a href="http://platform001.mixi.jp/run_appli.pl?id=6869" target="_blank">[mixi] 2ちゃんまとめRSSリーダー</a></p>
<p>mixiアプリおもしれいお（＾ｑ＾）</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/289/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[mixiアプリ] ユーザー情報を取得してみた。</title>
		<link>http://hiropo.co.uk/archives/284</link>
		<comments>http://hiropo.co.uk/archives/284#comments</comments>
		<pubDate>Sun, 23 Aug 2009 08:52:41 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=284</guid>
		<description><![CDATA[mixiでソーシャルアプリケーションアワードという開発者のためのイベントが行われているようです。 よくわかんないけど、mixiの情報を使って、アプリケーションが作れるmixiアプリを作って応募しよう！というものであるよう &#8230; <a href="http://hiropo.co.uk/archives/284">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>mixiで<a href="http://developer.mixi.co.jp/award" target="_blank">ソーシャルアプリケーションアワード</a>という開発者のためのイベントが行われているようです。<br />
よくわかんないけど、mixiの情報を使って、アプリケーションが作れるmixiアプリを作って応募しよう！というものであるようです。</p>
<p><a href="http://developer.mixi.co.jp/" target="_blank">mixiアプリ開発のためのサイト</a>までできている。<br />
で、このmixiアプリ、APIを公開しているので、APIを使ったAjax開発経験者なら誰でもすぐに開発ができるようです。mixiAPIは情報がリアルなユーザー情報だけに何だか面白そう！</p>
<p>ってなことで、mixiアプリに入門してみました。<br />
mixiアプリを開発するには公開環境を登録するみたいなことをしなきゃならないようです。<br />
（ここでは割愛します。）</p>
<p>まずは、mixiアプリの基盤ともいえるガジェットXMLを作ります。</p>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;module&gt;
  &lt;modulePrefs title=&quot;mixiアプリのてすとやねん&quot;&gt;
    &lt;require feature=&quot;opensocial-0.8&quot; /&gt;
  &lt;/modulePrefs&gt;
  &lt;content type=&quot;html&quot;&gt;&lt;![CDATA[

  &lt;!--||| head |||--&gt;

  &lt;!--||| StyleSheet |||--&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;http://funnythingz.com/mixi/test/css/style.css&quot; type=&quot;text/css&quot; media=&quot;screen,all&quot; /&gt;

  &lt;!--|| JavaScript FrameWork ||--&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;google.load(&quot;jquery&quot;, &quot;1.3.2&quot;);&lt;/script&gt;

  &lt;!--|| OriginalScript ||--&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;http://funnythingz.com/mixi/test/js/test.js&quot;&gt;&lt;/script&gt;

  &lt;!--||| /head |||--&gt;

  &lt;!--||| body |||--&gt;

  &lt;div id=&quot;dev_field&quot;&gt;&lt;/div&gt;

  &lt;!--||| /body |||--&gt;

  ]]&gt;&lt;/content&gt;
&lt;/module&gt;
</pre>
<p>HTMLの書き方わかる人なら、普通のHTMLを書くように、書けば特に問題なし。<br />
外部JSやCSSの読み込みもできる。</p>
<p>ちなみに、外部JSや外部CSSのパスは絶対パスで書くこと。<br />
ファイルは自分で用意したサーバに置く。</p>
<p>次に、外部CSSと外部JSを用意する。<br />
ガジェットXMLのみですべて済ませたい人はそれで特に問題なし。<br />
大規模な開発を行うならやはりファイルは分けておいたほうが後々わかり易い。</p>
<p>CSSはフィールド背景に色をつけてみた。<br />
これで出力される場所がわかる。</p>
<pre>
@charset "utf-8";
/*
*  mixiアプリ用CSS
*/

#dev_field {
  background: #ddd;
}
</pre>
<p>次にJSファイルの用意。コア部分のプログラミングになるので、JSは外部ファイルにすることを推奨。<br />
今回はmixiアプリにアクセスしたユーザー情報を取得してみる。</p>
<pre>
(function(){

  /******************************************************************************************************
  *
  *  mixiアプリAPIを使ってユーザー情報を取得してみる
  */
  /**-------------------------------------
  *  initを定義
  */
  function init() {

    /**-------------------------------------
    *  取得したい情報パラメータをセット
    */
    var params = {};
    params[ opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS ] = [
      opensocial.Person.Field.PROFILE_URL,
      opensocial.Person.Field.ADDRESSES,
      opensocial.Person.Field.AGE,
      opensocial.Person.Field.DATE_OF_BIRTH,
      opensocial.Person.Field.GENDER,
      opensocial.Person.Field.HAS_APP,
      mixi.PersonField.BLOOD_TYPE
    ];
    /**-------------------------------------
    *  リクエストを生成
    */
    var req = opensocial.newDataRequest();
    req.add( req.newFetchPersonRequest( opensocial.IdSpec.PersonId.VIEWER, params ), &#039;viewer&#039; );
    req.send(function( data ){

      /**--------------------------------------------------------------------------
      *  var プロフィール情報を取得
      */
      /**-------------------------------------
      *  エレメントセット
      */
      var element = $( &#039;#dev_field&#039; );

      /**-------------------------------------
      *  アプリを使用しているユーザー情報をセット
      */
      var viewer = data.get( &#039;viewer&#039; ).getData();

      //ニックネーム
      var user_name = viewer.getDisplayName();
      //ID
      var user_id = viewer.getId();
      //サムネイル画像
      var user_thumbnail = viewer.getField( opensocial.Person.Field.THUMBNAIL_URL );
      //プロフィールURL
      var user_url = viewer.getField( opensocial.Person.Field.PROFILE_URL );
      //出身地
      var user_pref = viewer.getField( opensocial.Person.Field.ADDRESSES)[0].getField(opensocial.Address.Field.UNSTRUCTURED_ADDRESS );
      //年齢
      var user_age = viewer.getField( opensocial.Person.Field.AGE );
      //誕生日
      var user_birth = viewer.getField( opensocial.Person.Field.DATE_OF_BIRTH );
      //性別
      var user_gender = viewer.getField( opensocial.Person.Field.GENDER ).getKey();
      //血液型
      var user_blood_type = viewer.getField( mixi.PersonField.BLOOD_TYPE );
      //このアプリをインストールしているか（戻り値:bool）
      var hasApp = viewer.getField( opensocial.Person.Field.HAS_APP );

      /**--------------------------------------------------------------------------
      *  プロフィール情報を使った処理
      */
      //HTMLテンプレート
      var template = &#039;&#039;;
      template += &#039;&lt;div&gt;[user_name] &#039;+ user_name +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_id] &#039;+ user_id +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_thumbnail]&lt;br /&gt;&lt;img src=&quot;&#039;+ user_thumbnail +&#039;&quot; alt=&quot;&#039;+ user_name +&#039;&quot; /&gt;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_url] &lt;a href=&quot;&#039;+ user_url +&#039;&quot; target=&quot;_blank&quot;&gt;&#039;+ user_url +&#039;&lt;/a&gt;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_pref] &#039;+ user_pref +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_age] &#039;+ user_age +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_birth] &#039;+ user_birth +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_gender] &#039;+ user_gender +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[user_blood_type] &#039;+ user_blood_type +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;
      template += &#039;&lt;div&gt;[hasApp] &#039;+ hasApp +&#039;&lt;/div&gt;&#039; + &quot;\n&quot;;

      //出力
      element.html( template );

    });

  }

  //init
  gadgets.util.registerOnLoadHandler( init );

})();
</pre>
<p>これで、ユーザー情報の取得ができる。<br />
あとは煮るなり焼くなり好きに調理してアプリを開発すればおｋ。</p>
<p>つくったmixiアプリの実行方法だが、<a href="http://platform001.mixi.jp/view_community.pl?id=3217244" target="_blank">mixiアプリ オープンβ</a>というコミュニティに参加しなくてはならない。<br />
まだβ版だから仕方ないのか？いまいちこのめんどくさい作業は省いてもらいたいなぁ。</p>
<p>他に指定IDのユーザー情報やマイミク一覧の情報なども取得できるよう。<br />
他APIと組み合わせてアプリを開発することも可能なので、けっこう盛り上がる予感がしますね。</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/284/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

