I’m struggling badly making a (apparently simple) php script for calling the twitter api and listing recent tweets. If anyone has any thoughts on this, I’m most appreciative. I THINK the crisis is in my require_once fucntion. Below the code is the link to it live, you can see what happens.
[php]<?php
session_start();
require_once(“twitteroauth.php”); //Path to twitteroauth library
$twitteruser = “username_here”;
$notweets = 10;
$consumerkey = “xxxxxxxxxxxxxxxx”;
$consumersecret = “xxxxxxxxxxxxxxxxxxxxx”;
$accesstoken = “xxxxxxxxxxxxxxxxxxxxxxj”;
$accesstokensecret = “xxxxxxxxxxxxxxxxx”;
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get(“https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=”.$notweets);
echo json_encode($tweets);
?>[/php]