{"id":3073,"date":"2017-06-14T14:36:35","date_gmt":"2017-06-14T05:36:35","guid":{"rendered":"http:\/\/apr20.net\/?p=3073"},"modified":"2017-06-14T14:36:35","modified_gmt":"2017-06-14T05:36:35","slug":"wordpress%e3%81%aerest-api%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e6%9c%80%e6%96%b0%e8%a8%98%e4%ba%8b%e3%82%92%e5%8f%96%e5%be%97%e3%83%bb%e8%a1%a8%e7%a4%ba%e3%81%95%e3%81%9b%e3%82%8b","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=3073","title":{"rendered":"WordPress\u306eREST API\u3092\u4f7f\u3063\u3066\u6700\u65b0\u8a18\u4e8b\u3092\u53d6\u5f97\u30fb\u8868\u793a\u3055\u305b\u308b"},"content":{"rendered":"<h2>1.WP REST API\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>\u7ba1\u7406\u753b\u9762\u304b\u3089\u300cWordPress REST API\u300d\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u6709\u52b9\u5316\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067<\/p>\n<blockquote><p>http:\/\/\u25ef\u25ef\u25ef.com\/wp-json\/wp\/v2\/posts<\/p><\/blockquote>\n<p>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308c\u3070\u3001\u8a18\u4e8b\u306e\u60c5\u5831\u304cjson\u5f62\u5f0f\u3067\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/developer.wordpress.org\/rest-api\/\" target=\"_blank\">WordPress REST API<\/a><\/p>\n<h2>json\u3092\u53d6\u5f97\u30fb\u8868\u793a\u3055\u305b\u308b<\/h2>\n<p>[php]&lt;?php<\/p>\n<p>\/\/WordPress\u306eURL\u3092\u6307\u5b9a\uff08\u65b0\u7740\u8a18\u4e8b2\u4ef6\u53d6\u5f97\uff09<br \/>\n$url = &#8216;http:\/\/\u25ef\u25ef\u25ef.com\/wp-json\/wp\/v2\/posts?_embed&amp;per_page=2&#8217;;<\/p>\n<p>$ch = curl_init(); \/\/ 1. \u521d\u671f\u5316<br \/>\ncurl_setopt( $ch, CURLOPT_URL, $url ); \/\/ 2. \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a<br \/>\ncurl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );<br \/>\n$result = curl_exec( $ch ); \/\/ 3. \u5b9f\u884c\u3057\u3066\u30c7\u30fc\u30bf\u3092\u5f97\u308b<br \/>\ncurl_close(); \/\/ 4. \u7d42\u4e86<\/p>\n<p>\/\/\u9023\u60f3\u914d\u5217\u306b\u3059\u308b<br \/>\n$arr_json = json_decode($result,true);<br \/>\n  \/\/ print_r($arr_json);<\/p>\n<p>     foreach ($arr_json as $json) {<br \/>\n$json_date = $json[&quot;date&quot;];<br \/>\n       $json_date = date(&#8216;Y\u5e74n\u6708j\u65e5&#8217;, strtotime($json_date));<br \/>\n$json_link = $json[&quot;link&quot;];<br \/>\n       $json_title = $json[&quot;title&quot;][&quot;rendered&quot;];<br \/>\n$json_img = $json[&quot;_embedded&quot;][&quot;wp:featuredmedia&quot;][0][&quot;media_details&quot;][&quot;sizes&quot;][&quot;full&quot;][&quot;source_url&quot;];<br \/>\n?&gt;<\/p>\n<p>      &lt;div class=&quot;detail&quot;&gt;<br \/>\n        &lt;?php \/\/\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u304c\u3042\u308b\u5834\u5408<br \/>\n            if($json_img) { ?&gt;<br \/>\n        &lt;div class=&quot;blog_img&quot;&gt;<br \/>\n          &lt;img src=&quot;&lt;?= $json_img; ?&gt;&quot; class=&quot;article_title_img&quot;&gt;<br \/>\n        &lt;\/div&gt;<br \/>\n        &lt;?php } ?&gt;<\/p>\n<p>        &lt;strong&gt;&lt;span class=&quot;date&quot;&gt;<br \/>\n        &lt;?= $json_date; ?&gt;<br \/>\n        &lt;\/span&gt;&lt;\/strong&gt;&lt;br&gt;<br \/>\n        &lt;a href=&quot;&lt;?= $json_link; ?&gt;&quot;&gt; &lt;span class=&quot;listTitle&quot;&gt;<br \/>\n        &lt;?= $json_title; ?&gt;<br \/>\n        &lt;\/span&gt; &lt;\/a&gt; &lt;\/div&gt;<\/p>\n<p>      &lt;?php<br \/>\n      \t\t\t}<br \/>\n?&gt;[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.WP REST API\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb \u7ba1\u7406\u753b\u9762\u304b\u3089\u300cWordPre&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,5],"tags":[],"class_list":["post-3073","post","type-post","status-publish","format-standard","hentry","category-php","category-wordpress-web-category"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/3073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3073"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/3073\/revisions"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}