'Get last tweet Twitter api
I try to show the last tweet from a specif user, using the Twitter API. When I try to echo the first result I get an empty page. When I echo my JSON data is see this.
I have the following PHP script:
<?php
require "Twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$consumer_key = "";
$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");
$statuses = $connection->get("statuses/user_timeline", ["screen_name" => "NS_online"], ["lang" => "NL"]);
//var_dump($statuses);
// get your json as an associative array
$jsonArray = json_decode($statuses, true);
print_r($jsonArray);
$test = $jsonArray[0]->created_at;
echo $test;
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|