I am trying to get a twitter feed working on my website. However whenever I load my page I get the following error:
XMLHttpRequest cannot load http://www.jciadt.com/demos/twitter/get_tweets.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://jciadt.com' is therefore not allowed access.
The page in question can be found here -> http://jciadt.com/demos/twitter/testindex.html
I don't know why this is happening. Any help would be greatly appreciated.
<?php
session_start();
require_once('http://jciadt.com/demos/twitter/twitteroauth/twitteroauth/twitteroauth.php');
$twitteruser = "jackcoldrick";
$notweets = 30;
$consumerkey="xxxxxxx";
$consumersecret="xxxxxxx";
$accesstoken="xxxxxxx-xxxxxxx";
$accesstokensecret="xxxxxxx";
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);
?>
wwwdistinction, then using a server side script to make the request for you is the most commonly used option.display_errorsturned on? Do you have any exceptions being logged? Double check all your variables and make sure your tokens and such are right and you're passing them in the right order, all that...I'm not familiar with Twitter, tbh...I've just started poking around the Google APIs.