Embedded Tweets work for one username/account but not another


#1

I am using script to display tweets on my website. I have two twitter accounts. When I use one twitter account username, it works fine. When I use the other, it doesn’t work. Why? I change nothing in the script except the username. Script below.

var tweetUsers = [‘gnax’];
var buildString = “”;

$(document).ready(function(){

$('#twitter-ticker').slideDown('slow');

for(var i=0;i<tweetUsers.length;i++)
{
	if(i!=0) buildString+='+OR+';
	buildString+='from:'+tweetUsers[i];
}

var fileref = document.createElement('script');

fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", "http://search.twitter.com/search.json?q="+buildString+"&callback=TweetTick&rpp=50");

document.getElementsByTagName("head")[0].appendChild(fileref);

});

function TweetTick(ob)
{
var container=$(’#tweet-container’);
container.html(’’);

$(ob.results).each(function(el){

	var str = '	<div class="tweet">\
				<div class="avatar"><a href="http://twitter.com/'+this.from_user+'" target="_blank"><img src="'+this.profile_image_url+'" alt="'+this.from_user+'" /></a></div>\
				<div class="user"><a href="http://twitter.com/'+this.from_user+'" target="_blank">'+this.from_user+'</a></div>\
				<div class="time">'+relativeTime(this.created_at)+'</div>\
				<div class="txt">'+formatTwitString(this.text)+'</div>\
				</div>';
	
	container.append(str);

});

container.jScrollPane();

}

function formatTwitString(str)
{
str=’ ‘+str;
str = str.replace(/((ftp|https?)://([-\w.]+)+(:\d+)?(/([\w/_.]*(?\S+)?)?)?)/gm,’$1’);
str = str.replace(/([^\w])@([\w-]+)/gm,’$1@$2’);
str = str.replace(/([^\w])#([\w-]+)/gm,’$1#$2’);
return str;
}

function relativeTime(pastTime)
{
var origStamp = Date.parse(pastTime);
var curDate = new Date();
var currentStamp = curDate.getTime();

var difference = parseInt((currentStamp - origStamp)/1000);

if(difference < 0) return false;

if(difference <= 5)				return "Just now";
if(difference <= 20)			return "Seconds ago";
if(difference <= 60)			return "A minute ago";
if(difference < 3600)			return parseInt(difference/60)+" minutes ago";
if(difference <= 1.5*3600) 		return "One hour ago";
if(difference < 23.5*3600)		return Math.round(difference/3600)+" hours ago";
if(difference < 1.5*24*3600)	return "One day ago";

var dateArr = pastTime.split(' ');
return dateArr[4].replace(/\:\d+$/,'')+' '+dateArr[2]+' '+dateArr[1]+(dateArr[3]!=curDate.getFullYear()?' '+dateArr[3]:'');

}


#2

Two things probably happening here:

  1. you’re using a deprecated API (search.twitter.com) that will stop working on May 7, 2013 – we recommend using Embedded Timeline widgets for this kind of thing instead

  2. The Search API isn’t a great source for tweets authored by a specific user – it doesn’t index all tweets and tends to service queries about events and places and things better than specific users. If you’re using the API to retrieve tweets by a specific user, using the user timeline API is a better bet.


#3