<?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>Branberyheag!! Lab &#187; JSONP</title>
	<atom:link href="http://lab.branberyheag.com/tag/jsonp/feed" rel="self" type="application/rss+xml" />
	<link>http://lab.branberyheag.com</link>
	<description>ActionScript3.0やJavascriptを使っていろんなものを作ってみます。</description>
	<lastBuildDate>Fri, 03 Feb 2012 06:28:02 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom:link rel='hub' href='http://lab.branberyheag.com/?pushpress=hub'/>
		<item>
		<title>JSONPでシンプルなサンプル</title>
		<link>http://lab.branberyheag.com/2011/04/20/jsonp%e3%81%a7%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aa%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab.html</link>
		<comments>http://lab.branberyheag.com/2011/04/20/jsonp%e3%81%a7%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aa%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab.html#comments</comments>
		<pubDate>Wed, 20 Apr 2011 12:00:42 +0000</pubDate>
		<dc:creator>isao</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[JSONP]]></category>

		<guid isPermaLink="false">http://lab.branberyheag.com/?p=1008</guid>
		<description><![CDATA[JSONPでPHPとJavascriptでのシンプルなサンプルを見つけたので、メモ。 参考サイト http://zapruder.main.jp/blog/?p=628関連した記事 wordpressの更新情報をJSON [...]]]></description>
			<content:encoded><![CDATA[<p>JSONPでPHPとJavascriptでのシンプルなサンプルを見つけたので、メモ。</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;pre&gt;var php='action.php';
var mc=document.createElement('script');
mc.type='text/javascript';
mc.src=php+'?callback=when_get_data';
document.getElementsByTagName('head')[0].appendChild(mc);

function when_get_data(m){
	m=eval(m);
	var a;
	var b=&quot;&quot;;
	for(a in m){
		b+=a+&quot;:&quot;+m[a]+&quot;\n&quot;;
	}
	get_item(&quot;output&quot;).innerHTML=b;
}&lt;/pre&gt;
</pre>
<pre class="brush: php; title: ; notranslate">
&lt;pre&gt;&lt;?php
$dat=array('name'=&gt;'John', birthday=&gt;'19731129', 'time'=&gt;date('Y/m/d H:i:s'));
$res='(' . json_encode($dat) . ')';
if($_GET['callback']){
	$res=$_GET['callback'] . '(\'' . $res . '\');';
}
header('Content-Type: text/javascript; charset=utf-8');
echo $res;
?&gt;&lt;/pre&gt;
</pre>
<p>参考サイト<br />
<a href="http://zapruder.main.jp/blog/?p=628">http://zapruder.main.jp/blog/?p=628</a><strong>関連した記事</strong>
<ul class="similar-posts">
<li><a href="http://lab.branberyheag.com/2010/01/17/wordpress%e3%81%ae%e6%9b%b4%e6%96%b0%e6%83%85%e5%a0%b1%e3%82%92jsonp%e3%81%a7%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95.html" rel="bookmark" title="2010年1月17日">wordpressの更新情報をJSONPで出力する方法</a></li>
<li><a href="http://lab.branberyheag.com/2011/02/04/939.html" rel="bookmark" title="2011年2月4日">シンプルな要素の高さを揃えるJavascript Tips</a></li>
<li><a href="http://lab.branberyheag.com/2011/10/26/css3%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%8a%e3%83%93%e3%82%b2%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab.html" rel="bookmark" title="2011年10月26日">CSS3アニメーションナビゲーションサンプル</a></li>
<li><a href="http://lab.branberyheag.com/2009/11/25/safari%e3%81%a7html%e4%b8%8a%e3%81%ab%e7%94%bb%e5%83%8f%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ae%e6%b3%a8%e6%84%8f%e7%82%b9.html" rel="bookmark" title="2009年11月25日">safariでHTML上に画像サイズを取得する際の注意点</a></li>
<li><a href="http://lab.branberyheag.com/2011/03/19/google-maps-api_on_ssl.html" rel="bookmark" title="2011年3月19日">Google Maps API でSSLが使えるようになった</a></li>
</ul>
<p><!-- Similar Posts took 3.358 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://lab.branberyheag.com/2011/04/20/jsonp%e3%81%a7%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aa%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wordpressの更新情報をJSONPで出力する方法</title>
		<link>http://lab.branberyheag.com/2010/01/17/wordpress%e3%81%ae%e6%9b%b4%e6%96%b0%e6%83%85%e5%a0%b1%e3%82%92jsonp%e3%81%a7%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95.html</link>
		<comments>http://lab.branberyheag.com/2010/01/17/wordpress%e3%81%ae%e6%9b%b4%e6%96%b0%e6%83%85%e5%a0%b1%e3%82%92jsonp%e3%81%a7%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95.html#comments</comments>
		<pubDate>Sun, 17 Jan 2010 12:23:21 +0000</pubDate>
		<dc:creator>isao</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[JSONP]]></category>

		<guid isPermaLink="false">http://lab.branberyheag.com/?p=534</guid>
		<description><![CDATA[wordpressの更新情報をJSONPで出力できるらしい。 試してみたら、結構いい感じに出力された。まぁ、別の見せ方で更新情報を出力したいときに役に立ちそう。 dogmap.jpさんのところで解説されていた。 以上のソ [...]]]></description>
			<content:encoded><![CDATA[<p>wordpressの更新情報をJSONPで出力できるらしい。<br />
試してみたら、結構いい感じに出力された。まぁ、別の見せ方で更新情報を出力したいときに役に立ちそう。</p>
<p><a href="http://dogmap.jp/2009/06/12/wordpress-jsonp/">dogmap.jpさん</a>のところで解説されていた。</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
include_once('./wp-load.php');

// パラメータ取得
$limit = (int) (isset($_GET['limit']) &amp;&amp; is_numeric($_GET['limit']) ? $_GET['limit'] : 5 );
$callback = wp_specialchars(attribute_escape(isset($_GET['callback']) ? $_GET['callback'] : 'callback'));
$charset = get_bloginfo('charset');

query_posts(&quot;showposts=$limit&quot;);		// 最終 $limit エントリ取得のループをつくる
if ( have_posts() ) {
	$out = null;

	// 最終 $limit エントリのタイトル・URL・日付を取得する
	while ( have_posts() ) {
		the_post();
		$out .= ( !empty($out) ? ',' : '');
		$out .= '{';
		$out .= '&quot;title&quot;:&quot;' . get_the_title() . '&quot;';
		$out .= ',&quot;link&quot;:&quot;' . get_permalink() . '&quot;';
		$out .= ',&quot;pubdate&quot;:&quot;' . the_date('Y-m-d H:i:s','','',false) . '&quot;';
		$out .= '}';
	}

	// JSONP 形式で書き出す
	nocache_headers();
	header(&quot;Content-Type: application/x-javascript; charset=$charset&quot;);
	echo &quot;$callback([$out]);&quot;;

} else {
	// 無ければ 404 Not Found を返す
	header(&quot;HTTP/1.0 404 Not Found&quot;);
	wp_die(&quot;404 Not Found&quot;);
}
?&gt;
</pre>
<p>以上のソースコードを記述したファイルをwordpressのルートに配置する。</p>
<p>http://www.exsample.jp/get_archives.php?limit=5&amp;callback=callback</p>
<p>にアクセスすると出力される。Javascriptで、callback関数を指定する。<br />
これで出力されたJSONPを別のHTMLに出力される。</p>
<p>コミュニティサイトで使えると思う。JSON APIとして用意してもいいかもしれない。</p>
<p>参考サイト<br />
<a href="http://dogmap.jp/2009/06/12/wordpress-jsonp/">WordPress の更新情報を JSONP 形式で出力</a><strong>関連した記事</strong>
<ul class="similar-posts">
<li><a href="http://lab.branberyheag.com/2011/04/20/jsonp%e3%81%a7%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aa%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab.html" rel="bookmark" title="2011年4月20日">JSONPでシンプルなサンプル</a></li>
<li><a href="http://lab.branberyheag.com/2010/02/08/gears-geolocation-api%e3%81%ab%e3%82%88%e3%82%8b%e4%bd%8d%e7%bd%ae%e6%83%85%e5%a0%b1%e5%8f%96%e5%be%97%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6.html" rel="bookmark" title="2010年2月8日">Gears Geolocation APIによる位置情報取得について</a></li>
<li><a href="http://lab.branberyheag.com/2010/04/05/%e3%82%b1%e3%83%bc%e3%82%bf%e3%82%a4%e3%81%a7gps%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6.html" rel="bookmark" title="2010年4月5日">ケータイでGPSを取得するライブラリについて</a></li>
<li><a href="http://lab.branberyheag.com/2010/04/21/twitter%e3%81%ae%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8d%e3%81%a8%e3%81%84%e3%81%a3%e3%81%97%e3%82%87%e3%81%ab%e4%bd%8d%e7%bd%ae%e6%83%85%e5%a0%b1%e3%82%92%e9%80%81%e4%bf%a1%e3%81%ab%e3%81%a4%e3%81%84.html" rel="bookmark" title="2010年4月21日">twitterのつぶやきといっしょに位置情報を送信について</a></li>
<li><a href="http://lab.branberyheag.com/2010/02/11/iphoneandroid%e3%81%ae%e7%8f%be%e5%9c%a8%e4%bd%8d%e7%bd%ae%e5%8f%96%e5%be%97%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81.html" rel="bookmark" title="2010年2月11日">iPhone/Androidの現在位置取得のまとめ</a></li>
</ul>
<p><!-- Similar Posts took 3.463 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://lab.branberyheag.com/2010/01/17/wordpress%e3%81%ae%e6%9b%b4%e6%96%b0%e6%83%85%e5%a0%b1%e3%82%92jsonp%e3%81%a7%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

