{"id":233,"date":"2015-01-19T17:31:34","date_gmt":"2015-01-19T08:31:34","guid":{"rendered":"https:\/\/fastcoding.jp\/blog\/?p=233"},"modified":"2020-01-05T20:28:09","modified_gmt":"2020-01-05T11:28:09","slug":"rss-get","status":"publish","type":"post","link":"https:\/\/fastcoding.jp\/blog\/all\/frontend\/rss-get\/","title":{"rendered":"RSS\u53d6\u5f97\u306f\u3069\u3046\u884c\u3046\u306e\u304b\uff1f"},"content":{"rendered":"<div class=\"the_content\"><p>\u5148\u65e5\u30da\u30fc\u30b8\u5185\u306bgoogle\u306eapi\u3092\u4f7f\u3063\u3066top\u30da\u30fc\u30b8\u306e\u30cb\u30e5\u30fc\u30b9\u60c5\u5831\u3084\u30d6\u30ed\u30b0\u60c5\u5831\u3092RSS\u53d6\u5f97\u306b\u3064\u3044\u3066\u884c\u3044\u307e\u3057\u305f\u3002<br \/>\n\u4f5c\u696d\u3068\u3057\u3066\u3057\u3066\u3044\u306a\u3044\u3068\u5fd8\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u81ea\u5206\u306e\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u5165\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" title=\"google api\u3000\u3092\u4f7f\u3063\u3066RSS\u53d6\u5f97\u65b9\u6cd5\" >&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\u201dja\u201d&gt;\r\n&lt;head&gt;\r\n\r\n&lt;script src=\"http:\/\/www.google.com\/jsapi\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\ngoogle.load(\"feeds\", \"1\"); \/\/API\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\r\n\r\nfunction initialize(){\r\n  \r\n  var feed = new google.feeds.Feed(\"\u8a72\u5f53\u306eblogURL\u3092\u5165\u308c\u307e\u3059\"); \/\/\u8aad\u307f\u8fbc\u3080\u30d5\u30a3\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\r\n  var noPhoto = (\"&lt;img src='' \/&gt;\"); \/\/\u753b\u50cf\u304c\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u8868\u793a\u3059\u308b\u753b\u50cf\u3092\u6307\u5b9a\u3057\u307e\u3059\r\n  \r\n  feed.setNumEntries(5); \/\/\u8a18\u4e8b\u3092\u8aad\u307f\u8fbc\u3080\u4ef6\u6570\u3092\u8a2d\u5b9a\u3057\u307e\u3059\r\n  feed.load(dispfeed);\r\n  \r\n  function dispfeed(result){\r\n\r\n    if(!result.error){\r\n      var container = document.getElementById(\"feed\"); \/\/HTML\u306b\u66f8\u304d\u51fa\u3059\u5bfe\u8c61\u306eID\u3092\u6307\u5b9a\u3057\u307e\u3059\r\n\r\n      for (var i = 0; i &lt; result.feed.entries.length; i++) {\r\n\r\n        var entry = result.feed.entries[i];\r\n        \r\n        var entryDate = new Date(entry.publishedDate); \/\/\u65e5\u4ed8\u53d6\u5f97\u3000\u4ee5\u4e0b\u4e8c\u6841\u51e6\u7406\u3092\u3057\u307e\u3059\r\n        var entryYear = entryDate.getYear();\r\n        if (entryYear &lt; 2000){\r\n          entryYear += 1900;\r\n        }\r\n        var entryMonth = entryDate.getMonth() + 1;\r\n        if (entryMonth &lt; 10) {\r\n          entryMonth = \"0\" + entryMonth;\r\n        }\r\n        var entryDay = entryDate.getDate();\r\n        if (entryDay &lt; 10) {\r\n          entryDay = \"0\" + entryDay;\r\n        }\r\n        var date = entryYear + \"\/\" + entryMonth + \"\/\" + entryDay ;\r\n\r\n        var entryImg = \"\";\r\n        var imgCheck = entry.content.match(\/(src=\"http:)[\\S]+((\\.jpg)|(\\.JPG)|(\\.jpeg)|(\\.JPEG)|(\\.gif)|(\\.GIF)|(\\.png)|(\\.PNG))\/); \/\/\u753b\u50cf\u306e\u30c1\u30a7\u30c3\u30af\u3092\u3057\u307e\u3059\r\n        if(imgCheck){\r\n          entryImg += '&lt;img ' + imgCheck[0] + '\" width=\"315\"&gt;';\r\n          } else {\r\n            entryImg += noPhoto;\r\n        }\r\n\r\n\/\/\u3053\u3053\u304b\u3089\u8a72\u5f53\u7b87\u6240\u306e\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\r\n\r\n        container.innerHTML += '&lt;div&gt;&lt;p class=\"textBlog\"&gt;' \r\n                  + date \r\n                  + '&lt;\/p&gt;&lt;h3 class=\"news-title\"&gt;'\r\n                  + entry.title + '&lt;\/h3&gt;'\r\n                  + entryImg  \r\n                  + '&lt;p class=\"mgt10\"&gt;'\r\n                  +entry.contentSnippet.substring(0,50)\r\n                  + '&lt;br&gt; \u2026&lt;a href=\"' + entry.link + '\"&gt;\u7d9a\u304d\u3092\u8aad\u3080&lt;\/a&gt;&lt;\/p&gt;&lt;\/div&gt;'\r\n                  +'&lt;hr&gt;';\r\n\r\n      }\r\n\r\n      var linkBlank = container.getElementsByTagName('a'); \/\/ target\u306b'_blank'\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u4e0d\u8981\u306a\u5834\u5408\u306f\u3001\u4ee5\u4e0b4\u884c\u3092\u524a\u9664\r\n      for (var j = 0, l = linkBlank.length; j &lt; l; j++) {\r\n        linkBlank[j].target = '';\r\n      } \/\/target'_blank'\u3053\u3053\u307e\u3067\r\n    }\r\n  }\r\n}\r\ngoogle.setOnLoadCallback(initialize);\/\/ JavaScript Document\r\n&lt;\/script&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;!--\u8a72\u5f53\u7b87\u6240\u306b--&gt;\r\n\r\n&lt;div id=\"feed\"&gt;&lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3042\u3068\u306f\u30b3\u30fc\u30c9\u53ca\u3073\u30af\u30e9\u30b9\u540d\u306e\u4fee\u6b63\u3092\u884c\u3048\u3070\u554f\u984c\u306a\u304f\u8868\u793a\u304c\u3055\u308c\u308b\u306f\u305a\uff01<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u5148\u65e5\u30da\u30fc\u30b8\u5185\u306bgoogle\u306eapi\u3092\u4f7f\u3063\u3066top\u30da\u30fc\u30b8\u306e\u30cb\u30e5\u30fc\u30b9\u60c5\u5831\u3084\u30d6\u30ed\u30b0\u60c5\u5831\u3092RSS\u53d6\u5f97\u306b\u3064\u3044\u3066\u884c\u3044\u307e\u3057\u305f\u3002 \u4f5c\u696d\u3068\u3057\u3066\u3057\u3066\u3044\u306a\u3044\u3068\u5fd8\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u81ea\u5206\u306e\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u307e\u3059\u3002 \u4e0b\u8a18\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u5165\u308c\u307e\u3059\u3002 &lt;!D [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":240,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-frontend"],"acf":[],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/fastcoding.jp\/blog\/wp-content\/uploads\/2015\/01\/PAK85_virssearch20140531500.jpg","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/posts\/233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/comments?post=233"}],"version-history":[{"count":5,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/posts\/233\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/posts\/233\/revisions\/241"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/media?parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/categories?post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastcoding.jp\/blog\/wp-json\/wp\/v2\/tags?post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}