202312 - Twitter API v2
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
require 'twifer.php';
|
||||
use Twifer\API;
|
||||
|
||||
class twitter
|
||||
{
|
||||
public static function tweet($message, $media='')
|
||||
{
|
||||
$twitter = new API(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
|
||||
|
||||
$postfields = "{\"text\":\"$message\"}";
|
||||
|
||||
if (($media != NULL)&&($media != '')){
|
||||
$img = $twitter->request('POST', 'media/upload', ['media' => $media]);
|
||||
$media_id=$img['media_id'];
|
||||
|
||||
$postfields = "{\"text\":\"$message\", \"media\": {\"media_ids\": [\"$media_id\"]}}";
|
||||
}
|
||||
|
||||
echo($postfields.PHP_EOL);
|
||||
|
||||
$res = $twitter->request('POST', '/2/tweets', $postfields);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public static function thanksRetweet()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public static function thanksFollowers()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user