I am extremely new to json and have been working on this issue for about a week.
I used php to retrieve tweets from a list of accounts and stored them into a .txt file
$cache = dirname(__FILE__) . '/../cache/twitter-json.txt';
$data = file_get_contents('http://api.twitter.com/1/lists/statuses.json? slug=widget&owner_screen_name=webcodepro&count=1&page=1&per_page=8&include_rts=true&include_entities=true');
$cachefile = fopen($cache, 'wb');
fwrite($cachefile,utf8_encode($data));
fclose($cachefile);
?>
The way the architect has the front-end page structured is that I need to store the json value (what I have in the .txt file) into a json variable in a .js file and render it.
edit:
so it has been changed to
$cache =_ _DIR__.'/cached.txt';
$data = file_get_contents('http://api.twitter.com/1/lists/statuses.json? slug=widget&owner_screen_name=webcodepro&count=1&page=1&per_page=8&include_rts=true&include_entities=true');
file_put_contents($cache, $data);
the file comes up empty. do you guys know what might be the problem?
Is it possible to store the contents of a .txt file into a json variable in a .js file?
utf8_encodethings as JSON is already UTF-8file_put_contentsfile_put_contents($cache, 'var myvar = '.$data.';');-edit-
Code to clarify my solution: