Closed ghost closed 7 years ago
Hi, there are tests showing different usages of the SDK.
Ignore media_ids as you're not uploading any media.
Does this look Correct? <?php
namespace Inactive-to-Reactive;
use pocketmine\plugin\PluginBase; use TwitterAPIExchange;
class Inactive-to-ReactiveExample extends PluginBase{
public function onLoad(){
$this->getLogger()->info("Plugin Loading");
}
public function onEnable(){
$this->getLogger()->info("Enabled Plugin");
$url = 'https://api.twitter.com/1.1/statuses/update.json';
$method = 'POST';
$params = array(
'status' => 'TEST TWEET TO BE DELETED' . rand(),
'possibly_sensitive' => false,
'media_ids' => self::$mediaId
);
$data = $this->exchange->request($url, $method, $params);
$expected = 'TEST TWEET TO BE DELETED';
$this->assertContains($expected, $data);
/** Store the tweet id for testStatusesDestroy() **/
$data = @json_decode($data, true);
$this->assertArrayHasKey('id_str', is_array($data) ? $data : array());
self::$tweetId = $data['id_str'];
/** We've done this now, yay **/
self::$mediaId = null;
}
public function onDisable(){
$this->getLogger()->info("Plugin Disabled");
}
}
should work i doubt the static self part should but in terms of sending it should in theory do it also ps, next time when you try to ask others about your code, try to do it in vanilla PHP, you cant expect everyone to know what pocketmine even is
Hello, Does anyone have a quick snippet of code that I could use to send a tweet?