wordpressで過去記事を自動ツイートするために下記のように書いているのですが、画面が真っ白になってしまいます。
どこが間違っているか、ご指摘頂けませんでしょうか?
ライブラリはこちら(https://github.com/themattharris/tmhOAuth)を使っています。
【functions.php】
php
1require_once 'tmhOAuth.php'; 2 function tweetPost(){ 3 //トークンなどの設定 4 $tmhOAuth = new tmhOAuth(array( 5 "consumer_key" => 'カスタマーキー', 6 "consumer_secret" => 'カスタマーシークレット', 7 "user_token" => 'アクセストークン', 8 "user_secret" => 'アクセストークンシークレット', 9 'curl_ssl_verifypeer' => false 10 )); 11 12 //ツイートする記事の取得 13 $post = get_posts(array( 14 'numberposts' => 1, 15 'orderby' => 'rand' 16 'post_type' => 'post', 17 'meta_key' => 'customfield01', 18 'meta_value' => 'customfield01on' 19 )); 20 21 //ツイートするテキスト 22 $params = array( 23 'status' => mb_strimwidth('【過去記事】'.strip_tags($post[0]->post_title), 0, 116, "...") . ' ' . get_permalink($post[0]->ID) 24 ); 25 26 //ツイートする処理 27 $code = $tmhOAuth->request( 28 'POST', 29 'https://api.twitter.com/1.1/statuses/update.json', 30 $params, 31 true, 32 true 33 ); 34 35 } 36 37 //Cronへ登録 38 add_action('tweetcron', 'tweetPost'); 39 function my_activation() { 40 if ( !wp_next_scheduled( 'tweetcron' ) ) { 41 wp_schedule_event(time(), 'hourly', 'tweetcron'); 42 } 43 } 44 add_action('wp', 'my_activation');
長いコードですみません。どうぞ宜しくお願い致します。
回答2件
あなたの回答
tips
プレビュー