-
Notifications
You must be signed in to change notification settings - Fork 2
/
guide_first.html
234 lines (188 loc) · 11.8 KB
/
guide_first.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="ja"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>guide_first</title>
<!-- InstanceEndEditable -->
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/prettify.css" rel="stylesheet">
<script src="js/prettify.js"></script>
<script src="js/jquery.js"></script>
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<!-- Le fav and touch icons -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body,td,th { font-family: Ubuntu, Tahoma, sans-serif; }
</style>
</head>
<body onload="prettyPrint()">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.html">OpenPNE3 JSON API ドキュメント</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<div class="row">
<div id="t_navi" class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">ガイド</li>
<li><a href="guide_first.html"><i class="icon-chevron-right"></i>ファーストステップガイド</a></li>
<li><a href="guide_template.html"><i class="icon-chevron-right"></i>テンプレート利用ガイド</a></li>
<li class="nav-header">API Ver. 3.8</li>
<li><a href="api_common.html"><i class="icon-chevron-right"></i>共通仕様</a></li>
<li class="nav-header">アクティビティ(タイムライン)</li>
<li><a href="activity_search.html"><i class="icon-chevron-right"></i>activity/search.json</a></li>
<li><a href="activity_member.html"><i class="icon-chevron-right"></i>activity/member.json</a></li>
<li><a href="activity_friends.html"><i class="icon-chevron-right"></i>activity/friends.json</a></li>
<li><a href="activity_community.html"><i class="icon-chevron-right"></i>activity/community.json</a></li>
<li><a href="activity_post.html"><i class="icon-chevron-right"></i>activity/post.json</a></li>
<li><a href="activity_delete.html"><i class="icon-chevron-right"></i>activity/delete.json</a></li>
<li><a href="activity_mentions.html"><i class="icon-chevron-right"></i>activity/mentions.json</a></li>
<li class="nav-header">メンバー</li>
<li><a href="member_community.html"><i class="icon-chevron-right"></i>member/community.json</a></li>
<li><a href="member_search.html"><i class="icon-chevron-right"></i>member/search.json</a></li>
<li><a href="member_friend_accept.html"><i class="icon-chevron-right"></i>member/friend_accept.json</a></li>
<li><a href="member_friend_request.html"><i class="icon-chevron-right"></i>member/friend_request.json</a></li>
<li class="nav-header">コミュニティ</li>
<li><a href="community_search.html"><i class="icon-chevron-right"></i>community/search.json</a></li>
<li><a href="community_member.html"><i class="icon-chevron-right"></i>community/member.json</a></li>
<li><a href="community_join.html"><i class="icon-chevron-right"></i>community/join.json</a></li>
<li class="nav-header">通知センター</li>
<li><a href="push_search.html"><i class="icon-chevron-right"></i>push/search.json</a></li>
<li><a href="push_count.html"><i class="icon-chevron-right"></i>push/count.json</a></li>
<li><a href="push_read.html"><i class="icon-chevron-right"></i>push/read.json</a></li>
<li class="divider"></li>
<li class="nav-header">開発版API Ver. 3.9.x〜</li>
<li class="nav-header">トピック</li>
<li><a href="topic_post.html"><i class="icon-chevron-right"></i>topic/post.json</a></li>
<li><a href="topic_delete.html"><i class="icon-chevron-right"></i>topic/delete.json</a></li>
<li><a href="topic_search.html"><i class="icon-chevron-right"></i>topic/search.json</a></li>
<li class="nav-header">トピックコメント</li>
<li><a href="topic_comment_post.html"><i class="icon-chevron-right"></i>topic_comment/post.json</a></li>
<li><a href="topic_comment_delete.html"><i class="icon-chevron-right"></i>topic_comment/delete.json</a></li>
<li><a href="topic_comment_search.html"><i class="icon-chevron-right"></i>topic_comment/search.json</a></li>
<li class="nav-header">イベント</li>
<li><a href="event_post.html"><i class="icon-chevron-right"></i>event/post.json</a></li>
<li><a href="event_delete.html"><i class="icon-chevron-right"></i>event/delete.json</a></li>
<li><a href="event_search.html"><i class="icon-chevron-right"></i>event/search.json</a></li>
<li class="nav-header">イベントコメント</li>
<li><a href="event_comment_post.html"><i class="icon-chevron-right"></i>event_comment/post.json</a></li>
<li><a href="event_comment_delete.html"><i class="icon-chevron-right"></i>event_comment/delete.json</a></li>
<li><a href="event_comment_search.html"><i class="icon-chevron-right"></i>event_comment/search.json</a></li>
<li class="nav-header">日記</li>
<li><a href="diary_post.html"><i class="icon-chevron-right"></i>diary/post</a></li>
<li><a href="diary_delete.html"><i class="icon-chevron-right"></i>diary/delete</a></li>
<li><a href="diary_search.html"><i class="icon-chevron-right"></i>diary/search</a></li>
<li><a href="diary_comment_post.html"><i class="icon-chevron-right"></i>diary_comment/post</a></li>
<li><a href="diary_comment_delete.html"><i class="icon-chevron-right"></i>diary_comment/delete</a></li>
<li><a href="diary_comment_search.html"><i class="icon-chevron-right"></i>diary_comment/search</a></li>
<!--
<li class="nav-header">ファイル</li>
<li><a href="file_upload.html"><i class="icon-chevron-right"></i>file/upload</a></li>
<li><a href="file_files.html"><i class="icon-chevron-right"></i>file/files</a></li>
<li><a href="file_search.html"><i class="icon-chevron-right"></i>file/search</a></li>
<li><a href="file_get.htm"><i class="icon-chevron-right"></i>lfile/get</a></li>
-->
</ul>
</div>
</div>
<div class="span9">
<div class="row">
<div class="span9">
<!-- InstanceBeginEditable name="EditMain" --> <h2>ファーストステップガイド</h2>
<p>OpenPNE3.8から新しく導入された、スマートフォンAPI。このAPIはスマートフォンだけでなくPCブラウザからでも、利用できるように設計されています。本ガイドでは、本APIを使うための第一歩をチュートリアル形式で説明します。</p>
<h2>APIでメンバー情報を取得する</h2>
<p>それではまず最初に、SNSのメンバー情報にアクセスするやり方を見ていきましょう。数行のJavaScriptコードを埋め込むだけでアクセスできます。</p>
<h3>0. 管理画面にログイン</h3>
<p>管理画面のHTML挿入機能でHTML挿入Aを選択します。</p>
<ul class="thumbnails"><li class="span5">
<a class="thumbnail" href="http://p.pne.jp/d/201207022247.png">
<img src="http://p.pne.jp/d/201207022247.png" alt="">
</a></li></ul>
<div class="alert alert-info"><strong>TIPS</strong> WEB画面にHTMLさえ埋め込めれば、フリーページガジェット、ソースコードの直接編集など、HTML挿入以外でもAPIを呼び出すことができます。</div>
<h3>1. JavaScriptコードを入力</h3>
<p>スマートフォンAPIを利用するJavaScriptコードを入力します。まずは以下のコードすべてをコピーして、HTML挿入のフォームに入力してください。</p>
<b>管理画面に挿入するコード</b>
<pre class="prettyprint linenums">
<script>
$(document).ready(function(){
var params = {};
params.apiKey = openpne.apiKey;
params.target = "member";
params.target_id = 1;
$.get('/api.php/member/search.json',params,function(json){
console.log(json);
alert("ID番のニックネームは[" + json.data[0]["name"] + "]です。");
});
});
</script>
</pre>
<h3>2. 動作確認</h3>
<p>SNSにログインしホーム画面を開くと、次のようなダイアログが表示されます。</p>
<img src="http://p.pne.jp/d/201204141417.png" alt="" />
<h3>3. APIの解説</h3>
<b>apiKey</b>
<p>OpenPNEログイン後の全ページのHTMLにはapiKeyがあらかじめセットされています。このキーをスマートフォンAPIのリクエストに含めることで、認証を行うことができます。</p>
<img src="http://p.pne.jp/d/529/201202081553.png">
<b>APIエントリポイント</b>
<p>メンバー検索では、エントリポイントとして、/api.php/member/search.json を利用します。</p>
<b>リクエストデータ</b>
メンバー検索ではリクエストデータとして、<b>target</b> <b>target_id</b>のふたつのパラメータを使用します。これらを<b>data</b>にセットします。
<b>$.get()メソッド</b>
スマートフォンAPIを呼び出す際には、jQueryの$.get()メソッドを利用します。
今回の例ではサーバからのレスポンスは、jsonデータに格納されます。
<h2>コミュニティリストをAJAX化する</h2>
<p>今度はHTMLタグを使って、実際にデザインを埋めこんでみます。OpenPNE3.8からは、デザインにjquery-templという、JavaScriptのテンプレートエンジンを使っています。スマートフォンAPI+jQuery+jquery-tmplで既存の9面テーブルを置き換えます。</p>
<h3>APIコール</h3>
<p>今回はapi.php/member/community.jsonを利用します。このAPIを使えば自分が所属するコミュニティのリストを取得することができます。member_id=5というように、引数を指定すればそのメンバーのコミュニティリストが取得できます。指定しない場合はAPIを呼び出した自分(閲覧者)のリストを取得します。
</p>
<blockquote>http://sns.example.com/api.php/member/community.json?apiKey=APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
</blockquote>
<p>呼び出しが成功した場合は、次のようなJSONデータが返ります。</p>
<a href="http://p.pne.jp/d/201205212203.png"><img src="http://p.pne.jp/d/500/201205212203.png" alt="" /></a>
<!-- InstanceEndEditable -->
</div><!--/span-->
</div><!--/row-->
</div><!--/span-->
</div><!--/row-->
<hr>
<footer>
<p>© Tejimaya Inc. 2012- All Rights Reserved.</p>
</footer>
</div><!--/.fluid-container-->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/bootstrap.js"></script>
</body>
<!-- InstanceEnd --></html>