{"id":3064,"date":"2017-05-30T13:16:48","date_gmt":"2017-05-30T04:16:48","guid":{"rendered":"http:\/\/apr20.net\/?p=3064"},"modified":"2017-05-30T13:16:48","modified_gmt":"2017-05-30T04:16:48","slug":"xml-rpc-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%a6wordpress%e3%81%ab%e8%a8%98%e4%ba%8b%e3%82%92%e6%8a%95%e7%a8%bf%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=3064","title":{"rendered":"XML-RPC \u3092\u5229\u7528\u3057\u3066wordpress\u306b\u8a18\u4e8b\u3092\u6295\u7a3f\u3059\u308b"},"content":{"rendered":"<h2>\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h2>\n<p>XML-RPC\u3092\u5229\u7528\u3059\u308b\u306e\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/code.google.com\/archive\/p\/php-ixr\/downloads\" target=\"_blank\" rel=\"noopener noreferrer\">IXR_Library.php\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/p>\n<p>[php]include_once(&quot;IXR_Library.php&quot;);<br \/>\n$client=new IXR_Client(&quot;http:\/\/wordpress-domain.com\/xmlrpc.php&quot;);[\/php]<\/p>\n<h2>\u65b0\u898f\u6295\u7a3f\u306e\u8a2d\u5b9a<\/h2>\n<p>[php]\t$wp_username=&quot;WP-USERNAME&quot;;<br \/>\n\t$wp_password=&quot;WP-PASSWORD&quot;;<\/p>\n<p>\t$postdate = new IXR_Date(mktime(0,0,0,4,20,2017));<br \/>\n\t$gmtpostdate = new IXR_Date(mktime(0,0,0,4,20,2017));  <\/p>\n<p>$url = &quot;http:\/\/~~&quot;;<\/p>\n<p>$status = $client-&gt;query(\t&#8216;metaWeblog.newPost&#8217;,<br \/>\n\t\t\t\t\t\t&#8221;,<br \/>\n\t\t\t\t\t\t$wp_username,<br \/>\n\t\t\t\t\t\t$wp_password,<br \/>\n\t\t\t\t\t\tarray(<br \/>\n  \t\t\t\t\t\t\t&#8216;title&#8217; =&gt; $title,<br \/>\n\t\t\t\t\t\t\t\t&#8216;description&#8217; =&gt; $description,<br \/>\n\t\t\t\t\t\t\t\t&#8216;dateCreated&#8217; =&gt; $postdate,<br \/>\n\t\t\t\t\t\t\t\t&#8216;date_created_gmt&#8217; =&gt; $gmtpostdate,<br \/>\n  \t\t\t\t\t\t\t\/\/ \u305d\u306e\u4ed6\u3001\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3001\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u3001\u30bf\u30b0\u306a\u3069\u3092\u3053\u3053\u3067\u8a2d\u5b9a\u53ef\u80fd\u2460<br \/>\n\t\t\t\t\t\t\t\t&#8216;post_status&#8217; =&gt; &#8216;publish&#8217;<br \/>\n\t\t\t\t\t\t\t),<br \/>\n\t\t\t\t\t\t2);\t\/\/ 0:\u4e0b\u66f8\u304d 1:\u516c\u958b 2:\u4e88\u7d04\u6295\u7a3f<\/p>\n<p> if($status){ echo &quot;\u6210\u529f&quot;;}<br \/>\nelse{ echo $client-&gt;getErrorMessage();}[\/php]<\/p>\n<h2>\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306a\u3069\u3092\u8a2d\u5b9a\u3059\u308b<\/h2>\n<p>\u4e0a\u306e\u30b3\u30fc\u30c9\u306e\u2460\u306e\u3042\u305f\u308a\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u306e\u5834\u5408\u306f\u30e1\u30c7\u30a3\u30a2ID\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u8a2d\u5b9a\u51fa\u6765\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u3053\u3061\u3089\u3067\u78ba\u8a8d\u51fa\u6765\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/codex.wordpress.org\/XML-RPC_MetaWeblog_API#metaWeblog.newPost\" target=\"_blank\">XML-RPC MetaWeblog API<\/a><\/p>\n<p>[php]<br \/>\n\/\/\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8a2d\u5b9a\u3059\u308b<br \/>\n\t &quot;custom_fields&quot; =&gt; array(<br \/>\n           array( &quot;key&quot; =&gt; &quot;url&quot;, &quot;value&quot; =&gt; $url ),<br \/>\n\t ),<br \/>\n\/\/\u30bf\u30b0\u3092\u8a2d\u5b9a\u3059\u308b<br \/>\n       &#8216;mt_keywords&#8217; =&gt;  array(&#8216;tag1&#8217;, &#8216;tag2&#8217;, &#8216;tag3&#8217;),<\/p>\n<p>\/\/\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u3092\u8a2d\u5b9a\u3059\u308b<br \/>\n&#8216;wp_post_thumbnail&#8217; =&gt; $img[&quot;id&quot;],[\/php]<\/p>\n<h2>\u753b\u50cf\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/h2>\n<p>[php]<br \/>\n$thumbnail_url = &quot;http:\/\/~~~~.png&quot;;<\/p>\n<p>$filename = pathinfo( $thumbnail_url );<br \/>\n$filename = $filename[&quot;basename&quot;];<br \/>\n$imgInfo = getimagesize($thumbnail_url);<br \/>\n$type = $imgInfo[&quot;mime&quot;];<\/p>\n<p>$bits = new IXR_Base64(file_get_contents($thumbnail_url));<br \/>\n$status1 = $client-&gt;query(<br \/>\n&quot;wp.uploadFile&quot;,<br \/>\n1,<br \/>\n$wp_username,<br \/>\n$wp_password,<br \/>\narray(<br \/>\n        &quot;name&quot; =&gt; $filename,<br \/>\n        &quot;type&quot; =&gt; $type,<br \/>\n        &quot;bits&quot; =&gt; $bits,<br \/>\n        &quot;overwrite&quot; =&gt; false,<br \/>\n        &quot;post_id&quot; =&gt; $post_id<br \/>\n)<br \/>\n);<br \/>\n$img = $client-&gt;getResponse();<br \/>\necho $client-&gt;getErrorMessage();<\/p>\n<p>\u6295\u7a3f\u3057\u305f\u753b\u50cf\u306e\u30e1\u30c7\u30a3\u30a2ID\u3092\u53d6\u5f97<br \/>\n$media_id = $img[&quot;id&quot;];<\/p>\n<p>[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 XML-RPC\u3092\u5229\u7528\u3059\u308b\u306e\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30c0&#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":[25,196],"class_list":["post-3064","post","type-post","status-publish","format-standard","hentry","category-php","category-wordpress-web-category","tag-a-a","tag-xml-rpc"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/3064","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=3064"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/3064\/revisions"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}