<?php

require_once 'twitteroauth/twitteroauth.php';
require_once 'config.php';
require_once '/usr/local/twitter/TomaTwiTest/logic/CommonConf.php';
$this_year = date("Y");
$commonConf = new CommonConf();
$authors = $commonConf->getCopyRightExpiredAuthorNames($this_year);
$messages = array();
if (count($authors) != 0) {
    foreach ($authors as $author) {
        $messages[] = "今年著作権が切れるのは" . $author . "です";
    }
}
var_dump($messages);
//    $conn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
//    tweetAuther($conn, $expired_message_array,"Expired");
function tweetAuther($conn, $messages, $debug = "debug")
{
    if (count($messages) == 0) {
        echo "This year No {$debug} Authers\n";
        return;
    }
    foreach ($messages as $message) {
        echo "{$debug} : tweet [{$message}]<br>";
        $status = array(status => $message);
        $result = $conn->post("statuses/update", $status);
        var_dump($result);
    }
}
Esempio n. 2
0
<?php

require_once 'twitteroauth/twitteroauth.php';
require_once 'config.php';
require_once '/usr/local/twitter/TomaTwiTest/logic/CommonConf.php';
$today = date("n-j");
$commonConf = new CommonConf();
$birth_author = $commonConf->getBirthAuthor($today);
$dead_author = $commonConf->getDiedAuthor($today);
if (count($birth_author) != 0) {
    $birth_message_array = array();
    foreach ($birth_author as $k => $v) {
        $year_old = date("Y") - $v['birth-year'];
        $author_wiki = "http://ja.wikipedia.org/wiki/" . urlencode($v['author']);
        $birth_message_array[] = "本日" . date("n月j日") . "誕生日の作家は," . $v['author'] . '(' . $author_wiki . ')' . "です。" . '(' . $v['birth-year'] . '年生,生誕' . $year_old . '年).  #' . $v['author'];
    }
}
if (count($dead_author) != 0) {
    $dead_message_array = array();
    foreach ($dead_author as $k => $v) {
        $year_after_dead = date("Y") - $v['dead-year'];
        $author_wiki = "http://ja.wikipedia.org/wiki/" . urlencode($v['author']);
        $dead_message_array[] = "本日" . date("n月j日") . "は," . $v['author'] . '(' . $author_wiki . ')' . "の没後" . $year_after_dead . "年です。  #" . $v['author'];
    }
}
$conn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
tweetAuther($conn, $birth_message_array, "Birth");
tweetAuther($conn, $dead_message_array, "Dead");
//var_dump(searchTweetByMessage($conn, "小田実"));
function getBirthAuther($date)
{
Esempio n. 3
0
<?php

require_once '/usr/local/twitter/TomaTwiTest/logic/CommonConf.php';
$commonConf = new CommonConf();
$list = $commonConf->getAuthorNames();
$api_url_base = "http://ws.zubapita-t.com/index.php?keywords=%s&type=xml&search=equal";
foreach ($list as $name) {
    echo "author = {$name}\n";
    $name = rtrim($name);
    $check_result = null;
    $api_url = str_replace('%s', $name, $api_url_base);
    $check_result = callRetry($api_url, 5);
    //$check_result    = simplexml_load_file($api_url);
    //$check_result = new SimpleXMLElement($check_xml);
    if ($check_result->error) {
        echo "{$name} calling [{$api_url}] failed\n\n";
        continue;
    }
    echo "check_result\n";
    echo "=========================\n";
    var_dump($check_result);
    echo "=========================\n";
    $no_data_flg = true;
    //write simple data
    $no_data_flg = writeSimpleXML($check_result, $name, $no_data_flg);
    /*
            if(isset($check_result->title)){
                 if($check_result->title == $name){
                     writeXML($check_result->lead, $name, "simple");
                 } else {
                     echo "$name simple xml is not defined\n";
Esempio n. 4
0
<?php

require_once '/usr/local/twitter/TomaTwiTest/logic/CommonConf.php';
$commonConf = new CommonConf();
$today = date("n-j");
var_dump($today);
var_dump($commonConf->getDiedAuthor($today));