Created
July 10, 2016 11:34
-
-
Save tetsugps/c7aef149c2792270a6cc7ee247f9b0f1 to your computer and use it in GitHub Desktop.
twitterBot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require "vendor/autoload.php"; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
define(CONSUMER_KEY, ''); | |
define(CONSUMER_SECRET, ''); | |
$access_token = ''; | |
$access_token_secret = ''; | |
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret); | |
$content = $connection->get("account/verify_credentials"); | |
$tweet = $connection->get("search/tweets", array("q" => "薬 -RT -to:@* -#* -filter:links", 'count' => 1)); | |
$id = $tweet->statuses[0]->user->id; | |
$rep = $tweet->statuses[0]->text; | |
$name = $tweet->statuses[0]->user->name; | |
$pos = strpos($rep,"@"); | |
if($pos == 0) $rep = mb_substr($rep, strpos($rep," ")); | |
if(empty($rep)) $rep = "No tweets found"; | |
$statues = $connection->post("statuses/update", ["status" => $rep]); | |
$params = array( | |
'user_id' => $id, | |
//'screen_name'=>"", | |
'follow'=> 'true', | |
); | |
$addFriend = $connection->post("friendships/create", $params); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment