2019-03-31 11:00:21 +00:00
|
|
|
|
---
|
|
|
|
|
title: rfc.jsonを使ってみる
|
|
|
|
|
author: kazu634
|
|
|
|
|
date: 2010-12-23
|
|
|
|
|
wordtwit_post_info:
|
|
|
|
|
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:5401;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
|
|
|
|
|
categories:
|
|
|
|
|
- gauche
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
<div class="section">
|
|
|
|
|
<p>
|
|
|
|
|
Gauche の新機能検証をしているように見えますが、単純に Foursquare API を利用するスクリプトを作っているんです。たまたま最新バージョンで HTTPS 接続や、 json が利用出来るようになっているだけでして。。。
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
rfc.json、使い方はとても簡単でした:
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<pre class="syntax-highlight">
|
|
|
|
|
gosh> <span class="synSpecial">(</span>use rfc.json<span class="synSpecial">)</span>
|
|
|
|
|
#<undef>
|
|
|
|
|
gosh> <span class="synSpecial">(</span>receive <span class="synSpecial">(</span>status header body<span class="synSpecial">)</span>
|
|
|
|
|
<span class="synSpecial">(</span>http-get <span class="synConstant">"api.foursquare.com"</span>
|
|
|
|
|
<span class="synSpecial">(</span>string-append
|
|
|
|
|
<span class="synConstant">"/v2/users/self/checkins?oauth_token="</span>
|
|
|
|
|
<span class="synConstant">"私の oauth_token"</span>
|
|
|
|
|
<span class="synConstant">"&limit=3"</span><span class="synSpecial">)</span>
|
|
|
|
|
:secure #t<span class="synSpecial">)</span>
|
|
|
|
|
<span class="synSpecial">(</span>parse-json-string body<span class="synSpecial">))</span>
|
|
|
|
|
<span class="synSpecial">((</span><span class="synConstant">"meta"</span> <span class="synSpecial">(</span><span class="synConstant">"code"</span><span class="synStatement"> . </span><span class="synConstant">200</span><span class="synSpecial">))</span> <span class="synSpecial">(</span><span class="synConstant">"response"</span> <span class="synSpecial">(</span><span class="synConstant">"checkins"</span> <span class="synSpecial">(</span><span class="synConstant">"count"</span><span class="synStatement"> . </span><span class="synConstant">1963</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"items"</span><span class="synStatement"> . </span>#<span class="synSpecial">(((</span><span class="synConstant">"id"</span><span class="synStatement"> . </span><span class="synConstant">"4d12f47c37f1236aaafd7d1b"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"createdAt"</span><span class="synStatement"> . </span><span class="synConstant">1293087868</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"type"</span><span class="synStatement"> . </span><span class="synConstant">"checkin"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"shout"</span><span class="synStatement"> . </span><span class="synConstant">"勉強してます。"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"isMayor"</span><span class="synStatement"> . </span>true<span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"venue"</span> <span class="synSpecial">(</span><span class="synConstant">"id"</span><span class="synStatement"> . </span><span class="synConstant">"4c131b17b7b9c9280320a937"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"name"</span><span class="synStatement"> . </span><span class="synConstant">"STICK SWEETS FACTORY サクラス戸塚店"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"contact"</span> <span class="synSpecial">(</span><span class="synConstant">"phone"</span><span class="synStatement"> . </span><span class="synConstant">"0458654511"</span><span class="synSpecial">))</span> <span class="synSpecial">(</span><span class="synConstant">"location"</span> <span class="synSpecial">(</span><span class="synConstant">"address"</span><span class="synStatement"> . </span><span class="synConstant">"戸塚町4253-1"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"city"</span><span class="synStatement"> . </span><span class="synConstant">"横浜市戸塚区"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"state"</span><span class="synStatement"> . </span><span class="synConstant">"神奈川県"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"postalCode"</span><span class="synStatement"> . </span><span class="synConstant">"244-0003"</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"lat"</span><span class="synStatement"> . </span><span class="synConstant">35.40073452467999</span><span class="synSpecial">)</span> <span class="synSpecial">(</span><span class="synConstant">"lng"</span><span class="synStatement"> . </span><span class="synConstant">139.53113079071045</span><span class="synSpecial">))</span> <span class="synSpecial">(</span><span class="synConstant">"categories"</span><span class="synStatement"> . </span>#<span class="synSpecial">(((</span><span class="synConstant">"id"</span><
|
|
|
|
|
<span class="synSpecial">(</span><span class="synConstant">"count"</span><span class="synStatement"> . </span><span class="synConstant"></span><span class="synSpecial">)))))))))</span>
|
|
|
|
|
</span></pre>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
XMLの場合だと、 XPATH を指定することで簡単に任意の場所からのS式を切り出せたけど、この場合は自分で切り出すしか無いのかな?こんな感じかな?
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<pre class="syntax-highlight">
|
|
|
|
|
<span class="synSpecial">(</span><span class="synStatement">assoc</span> <span class="synConstant">"items"</span>
|
|
|
|
|
<span class="synSpecial">(</span><span class="synStatement">assoc</span> <span class="synConstant">"checkins"</span>
|
|
|
|
|
<span class="synSpecial">(</span><span class="synStatement">assoc</span> <span class="synConstant">"response"</span>
|
|
|
|
|
<span class="synType">*json-response*</span><span class="synSpecial">)))</span>
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
面倒くさい気がする。
|
|
|
|
|
</p>
|
2019-04-02 16:06:15 +00:00
|
|
|
|
</div>
|