{"id":224660,"date":"2018-01-28T01:56:01","date_gmt":"2018-01-27T16:56:01","guid":{"rendered":"https:\/\/ja.wordpress.org\/support\/topic\/%e6%af%8e%e6%97%a5%ef%bc%91%ef%bc%93%e6%99%82%e3%81%ab%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%e8%87%aa%e5%8b%95%e3%83%84%e3%82%a4%e3%83%bc%e3%83%88%e6%a9%9f%e8%83%bd\/"},"modified":"2018-01-28T02:01:32","modified_gmt":"2018-01-27T17:01:32","slug":"%e6%af%8e%e6%97%a5%ef%bc%91%ef%bc%93%e6%99%82%e3%81%ab%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%e8%87%aa%e5%8b%95%e3%83%84%e3%82%a4%e3%83%bc%e3%83%88%e6%a9%9f%e8%83%bd","status":"publish","type":"topic","link":"https:\/\/ja.wordpress.org\/support\/topic\/%e6%af%8e%e6%97%a5%ef%bc%91%ef%bc%93%e6%99%82%e3%81%ab%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%e8%87%aa%e5%8b%95%e3%83%84%e3%82%a4%e3%83%bc%e3%83%88%e6%a9%9f%e8%83%bd\/","title":{"rendered":"\u6bce\u65e5\uff11\uff13\u6642\u306b\u5b9f\u884c\u3059\u308b\u81ea\u52d5\u30c4\u30a4\u30fc\u30c8\u6a5f\u80fd"},"content":{"rendered":"<p>\u9996\u8a18\u306e\u3068\u304a\u308a\u3067\u3059\u304c\u3001<\/p>\n<p>\u2780\u6307\u5b9a\u3057\u305f\u6642\u523b\u306b\u6bce\u65e5\uff11\u56de<br \/>\n\u2781\u30e9\u30f3\u30c0\u30e0\u306a\u8a18\u4e8b\u3092\u30c4\u30a4\u30fc\u30c8\u3059\u308b<\/p>\n<p>\u3068\u3044\u3046\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u2780\u304c\u3069~~~\u3057\u3066\u3082\u3001\u3046\u307e\u304f\u3044\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u4e0b\u8a18\u3088\u3046\u306b\u66f8\u3044\u3066\u304a\u308a\u3001\u307e\u3063\u305f\u304f\u5b9f\u884c\u3055\u308c\u306a\u3044\u72b6\u614b\u3067\u3059\u3002<\/p>\n<p>\u203b\u6642\u523b\u6307\u5b9a\u306a\u3051\u308c\u3070\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067\u3001\u3010\u4ee5\u4e0b\u306b\u9593\u9055\u3044\u304c\u3042\u308b\u30cf\u30ba\u3011\u306b\u9593\u9055\u3044\u304c\u3042\u308b\u30cf\u30ba\u3067\u3059\u3002<\/p>\n<p>\u3069\u306a\u305f\u304b\u3001\u9593\u9055\u3063\u305f\u3068\u3053\u308d\u3092\u3054\u6307\u6458\u9802\u3051\u307e\u305b\u3093\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<pre><code>require_once dirname(__FILE__) . &#039;\/tmhOAuth-master\/tmhOAuth.php&#039;;\n    function tweetPost(){\n        \/\/\u30c8\u30fc\u30af\u30f3\u306a\u3069\u306e\u8a2d\u5b9a\n        $tmhOAuth  = new tmhOAuth(array(\n            &quot;consumer_key&quot;    =&gt; &#039;xxx&#039;,\n            &quot;consumer_secret&quot; =&gt; &#039;xxx&#039;,\n            &quot;user_token&quot;      =&gt; &#039;xxx&#039;,\n            &quot;user_secret&quot;     =&gt; &#039;xxx&#039;,\n            &#039;curl_ssl_verifypeer&#039; =&gt; false\n        ));\n\n        \/\/\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u8a18\u4e8b\u306e\u53d6\u5f97\n        $post = get_posts(array(\n            &#039;numberposts&#039; =&gt; &#039;1&#039;,\n            &#039;orderby&#039;     =&gt; &#039;rand&#039;,\n            &#039;post_type&#039;   =&gt; &#039;post&#039;,\n            &#039;meta_key&#039;    =&gt; &#039;checkbox_on&#039;,\n            &#039;meta_value&#039;  =&gt; &#039;on&#039;,\n        ));\n\n        \/\/\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u30c6\u30ad\u30b9\u30c8\n        $custom_title = empty($post[0]-&gt;post_title) ? &#039;\u7121\u984c&#039; : $post[0]-&gt;post_title;\n        $params = array(\n        &#039;status&#039; =&gt; mb_strimwidth($custom_title.&#039;\u3092\u6295\u7a3f\u3057\u307e\u3057\u305f\u3002&#039;, 0, 116, &quot;...&quot;) . &#039; &#039; . get_permalink($post[0]-&gt;ID)\n        );\n\n        \/\/\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u51e6\u7406\n        $code = $tmhOAuth-&gt;request(\n            &#039;POST&#039;,\n            &#039;https:\/\/api.twitter.com\/1.1\/statuses\/update.json&#039;,\n            $params,\n            true,\n            true\n        );\n    }\n\tadd_action( &#039;tweetPost&#039;, &#039;tweetPost&#039; );\n\n\/**\n * \u3010\u4ee5\u4e0b\u306b\u9593\u9055\u3044\u304c\u3042\u308b\u30cf\u30ba\u3011\n * ----------------------------------------------------------------------------\n *\/\t\n\t\n    \/\/Cron\u3078\u767b\u9332\n    function my_activation(){\n    if ( ! wp_next_scheduled( &#039;tweetcron&#039; ) ) {\n        \/\/\u6642\u5dee\u3092\u6c42\u3081\u308b\n        $p = ( current_time( &#039;timestamp&#039; ) - time( ) ) \/ 3600;\n\n        \/\/(\u4eca\u65e5\u304b\u3089)\u6bce\u65e5\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3059\u308b\u6642\u9593\u3092\u8a2d\u5b9a\u3059\u308b\n        \/\/\u7ba1\u7406\uff1e\u8a2d\u5b9a\u3055\u308c\u305f\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u3067\u306e\u6642\u9593\u3092\u8a2d\u5b9a\u3059\u308b(13:00)\n        $my_time = date( &#039;Y-m-d 13:00:00&#039;, current_time( &#039;timestamp&#039; ) );\n\n        \/\/\u6642\u5dee\u3092\u5f15\u3044\u3066\u3001UNIX\u6642\u9593(UTC:\u79d2)\u306b\u5408\u308f\u305b\u308b\n        $task_time = strtotime( -1 * $p.&quot; hour&quot;, strtotime( $my_time ) );\n        wp_schedule_event( $task_time, &#039;daily&#039;, tweetcron ,array(strtotime( $my_time )));\n        }\n    }\n    add_action(&#039;wp&#039;, &#039;my_activation&#039;);<\/code><\/pre>\n<p>\u5c1a\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u300ctmhOAuth\uff08<a href=\"https:\/\/github.com\/themattharris\/tmhOAuth\">https:\/\/github.com\/themattharris\/tmhOAuth<\/a>\uff09\u300d\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3069\u3046\u305e\u5b9c\u3057\u304f\u304a\u9858\u3044\u81f4\u3057\u307e\u3059\u3002&lt;(_ _)&gt;<\/p>\n<p>\u203b\u3061\u306a\u307f\u306b\u3001\u4f3c\u305f\u8cea\u554f\u3067<a href=\"https:\/\/ja.wordpress.org\/support\/topic\/%e3%82%b9%e3%82%b1%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%81%a6%e3%81%8f%e3%82%8c%e3%81%be%e3%81%9b%e3%82%93\/#post-224661\">https:\/\/ja.wordpress.org\/support\/topic\/%e3%82%b9%e3%82%b1%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%81%a6%e3%81%8f%e3%82%8c%e3%81%be%e3%81%9b%e3%82%93\/#post-224661<\/a>\u304c\u3054\u3056\u3044\u307e\u3059\u304c\u3001\u300c\u4eca\u56de\u306e\u306f\u6307\u5b9a\u6642\u523b\u30d0\u30fc\u30b8\u30e7\u30f3\u300d\u3067\u30ea\u30f3\u30af\u5148\u306f\u300c\u6bce\u6642\u9593\u30d0\u30fc\u30b8\u30e7\u30f3\u300d\u306a\u306e\u3067\u3001\u5225\u8cea\u554f\u306b\u3055\u305b\u3066\u9802\u304d\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"template":"","class_list":["post-224660","topic","type-topic","status-publish","hentry","topic-tag-14258","topic-tag-26078","topic-tag-twitter","topic-tag-wp-cron"],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/224660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/224660\/revisions"}],"predecessor-version":[{"id":224662,"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/224660\/revisions\/224662"}],"wp:attachment":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=224660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}