The best solution for javascript-based Twitter and Flickr api calls when using WordPress is to use the WordPress Transient API. The Transient API is a persistent cache method built in to WordPress meant to cache items that change frequently. You can set the cache expires time and WordPress will check the database first for the transient if it returns false it will use the json call to return the item.
Here is an example using a transient and shortcodes to store a users most recent tweet. The code below is from Aaron Jorbin Twitter Transients Plugin
function twitter_status($atts){
extract(shortcode_atts(array(
'screenname' => '',
'count' => 1
), $atts));
$transient = "$screenname"."_$count"."_twitter_status";
$statuses = get_transient($transient);
if ($statuses == true )
{
return $statuses;
}
elseif ($screenname != false)
{
$site = "http://twitter.com/statuses/user_timeline.json?screen_name=$screenname&count=$count";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $site);
$result = curl_exec($ch);
$tweets = json_decode($result);
ob_start();
foreach ( (array) $tweets as $tweet){
$tweetcontent = $tweet->text;
$newcontent = preg_replace('%@([^\s]*)%', "<a href="http://twitter.com/\\1">@\\1</a>", $tweetcontent);
echo "<div class="twitter_shortcode"><p>
<img class="twitter_shortcode_image" src="".esc_url($tweet->user->profile_image_url).""><span class="twitter_shotcode_username"><a href="http://twitter.com/".$tweet->user->screen_name."">".$tweet->user->screen_name."</a> — </span>$newcontent</p>
</div>";
}
$tweet_display = ob_get_clean();
set_transient($transient, $tweet_display, 120);
return $tweet_display;
}
else
{
return false;
}
}
add_shortcode('twitter_status', 'twitter_status');