過去ログツイートのテスト

  • タグ:
  • タグはありません
require_once 'tmhOAuth.php';
function tweetPost(){
if($_GET['tweet'] == 1){ //http://example.com?tweet=1
//
$tmhOAuth = new tmhOAuth(array(
"consumer_key" => '',
"consumer_secret" => '',
"user_token" => '',
"user_secret" => '',
'curl_ssl_verifypeer' => false //SSL
));
//
//get_posts
$post = get_posts(array(
'numberposts' => 1,
'orderby' => 'rand'
));
//使調
//URLpost_title
$params = array(
'status' => mb_strimwidth(''.strip_tags($post[0]->post_content), 0, 116, "...") . ' ' . get_permalink($post[0]->ID)
);
//
$code = $tmhOAuth->request(
'POST',
'https://api.twitter.com/1.1/statuses/update.json',
$params,
true,
true
);
/*
$file = wp_get_attachment_image_src( get_post_thumbnail_id($post[0]->ID), 'full' );
$file = $file[0];
$image = file_get_contents( $file );
$imagesize = getimagesize( $file );
$params = array(
'status' => mb_strimwidth(''.strip_tags($post[0]->post_content), 0, 116, "...") . ' ' . get_permalink($post[0]->ID),
'media[]' => $image . ";type=" . $imagesize['mime'] . ";filename=" . basename( $file )
);
//URL
$code = $tmhOAuth->request(
'POST',
'https://api.twitter.com/1.1/statuses/update_with_media.json',
$params,
true,
true
);
*/
} //if
}
add_action('wp_head','tweetPost'); //headerinitGET
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX