Пример #1
0
function post_tweets($post_texts, $userdata)
{
    foreach ($post_texts as $i => $text) {
        echo 'POST:' . PHP_EOL;
        echo $text . PHP_EOL;
        if (DEBUG) {
            continue;
        }
        $to = new TwistOAuth($userdata->twitter_consumer_key, $userdata->twitter_consumer_key_secret, $userdata->twitter_access_token, $userdata->twitter_access_token_secret);
        $url = 'statuses/update';
        $param = array('status' => $text);
        try {
            $res = $to->post($url, $param);
        } catch (TwistException $e) {
            var_dump($e);
        }
    }
}
Пример #2
0
function template_tweet()
{
    global $array, $CK, $CS, $AT, $AS, $hashtag;
    printstr($array);
    print "gochiusa/temp > ";
    $stdin = trim(fgets(STDIN));
    try {
        $to = new TwistOAuth($CK, $CS, $AT, $AS);
        while (!($stdin === "exit")) {
            echo "you tweet ";
            echo $array[$stdin] . " #" . $hashtag . "\n";
            $to->post('statuses/update', array('status' => $array[$stdin] . " #" . $hashtag));
            printstr($array);
            print "gochiusa/temp > ";
            $stdin = trim(fgets(STDIN));
        }
    } catch (TwistException $e) {
        //set error message
        $error = $e->getMessage();
        $code = $e->getCode() ?: 500;
    }
}
Пример #3
0
 * Created by PhpStorm.
 * User: kmasaya
 * Date: 30/11/2015
 * Time: 19:07
 */
if (empty($argv[1])) {
    exit('Usage:php cron.php screen_name' . PHP_EOL);
}
$screen_name = $argv[1];
if (!empty($argv[2])) {
    $rcount = $argv[2];
} else {
    $rcount = 3;
}
require '../config.php';
require 'TwistOAuth.phar';
$to = new TwistOAuth(CK, CS, AT, ATS);
$count = '5000';
//取得数
//$rcount = '20';      //リムーブ数
/* Follow取得 */
$follow = $to->get('friends/ids', array('screen_name' => $screen_name, 'count' => $count));
/* FollowerID取得 */
$follower = $to->get('followers/ids', array('screen_name' => $screen_name, 'count' => $count));
$f_difference = array_diff($follow->ids, $follower->ids);
$remove = array_slice($f_difference, 0, $rcount);
foreach ($remove as $rem) {
    $to->post('friendships/destroy', array('user_id' => $rem));
    print $rem . ' ';
    sleep(3);
}
Пример #4
0
 * Date: 2015/12/02
 * Time: 13:05
 */
if (empty($argv[1])) {
    exit('Usage:php cron.php screen_name' . PHP_EOL);
}
$screen_name = $argv[1];
if (!empty($argv[2])) {
    $fcount = $argv[2];
} else {
    $fcount = 3;
}
require '../config.php';
require 'TwistOAuth.phar';
$to = new TwistOAuth(CK, CS, AT, ATS);
$count = '5000';
//取得数
$myscreen_name = 'HaloDsny';
//自分のTwitter名
/* MyFollowing取得 */
$mefollowing = $to->get('friends/ids', array('screen_name' => $myscreen_name, 'count' => $count));
/* Target FollowerID取得 */
$target = $to->get('followers/ids', array('screen_name' => $screen_name, 'count' => $count));
$f_difference = array_diff($target->ids, $mefollowing->ids);
//自フォローとターゲットフォロワー差分
$following = array_slice($f_difference, 100, $fcount);
foreach ($following as $fol) {
    $to->post('friendships/create', array('user_id' => $fol));
    print $fol . ' ';
    sleep(5);
}
Пример #5
0
<?php

require_once 'lib/TwistOAuth.php';
require_once 'lib/TwistException.php';
define('CONSUMER_KEY', '取得したキー');
define('CONSUMER_SECRET', '取得したキー');
define('ACCESS_TOKEN', '取得したキー');
define('ACCESS_TOKEN_SECRET', '取得したキー');
try {
    $to = new TwistOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
} catch (TwistException $e) {
    $error = $e->getMessage();
    echo $error . PHP_EOL;
}
// tweet text
$text = "そろそろ行くか";
// parameter
$params = array("status" => $text);
// end point
$url = "https://api.twitter.com/1.1/statuses/update.json";
$to->post($url, $params);
Пример #6
0
 function tweet($text)
 {
     $to = new TwistOAuth(TWITTER_COSUMER_KEY, TWITTER_COSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_TOKEN_SECRET);
     $to->post('statuses/update', array('status' => $text));
 }