/** * @depends testLastResult */ public function testResetLastResponse() { $this->twitter->resetLastResponse(); $this->assertEquals('', $this->twitter->getLastApiPath()); $this->assertEquals(0, $this->twitter->getLastHttpCode()); $this->assertEquals(array(), $this->twitter->getLastBody()); }
function block_twitter_get_tweets($handle) { global $CFG, $COURSE, $DB; $cache = cache::make('block_twitter', 'tweets'); $tweets = $cache->get('tweets_' . $handle); if ($tweets !== false) { return $tweets; } $tconf = get_config('block_twitter'); $connection = new TwitterOAuth($tconf->consumerkey, $tconf->consumersecret, $tconf->accesstoken, $tconf->accesssecret); $connection->resetLastResponse(); $tweets = $connection->get("statuses/user_timeline", ["screen_name" => $handle, 'exclude_replies' => true, 'trim_user' => false]); if (isset($tweets->errors)) { $error = reset($tweets->errors); debugging(get_string('error') . ' ' . $error->code . ': ' . $error->message, DEBUG_DEVELOPER); return ''; } $cache->set('tweets_' . $handle, $tweets); return $tweets; }