you are here: codestackercodes [RSS] → tag json [RSS]

show flickr photos with javascript

<script type="text/javascript">
function jsonFlickrFeed(o){
	var i = 0;
	while(o.items[i]){
    	document.write('<img src="' + o.items[i].media.m + '" alt="' + o.items[i].title +'">');
   		i++;
	}
}
</script>
<script src="http://api.flickr.com/services/feeds/photos_public.gne?id=28203925@N08&lang=en-us&format=json" type="text/javascript"></script>

Traduz textos usando o google

Traduz palavras/frases/textos usando a API do Google, usei aqui http://github.com/rafaelss/shoes-translator

require 'rest_client'
require 'json'
require 'cgi'

word = CGI.escape("hello world")
response = RestClient.get "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=#{word}&langpair=en%7Cpt"
json = JSON.parse(response)
status = json['responseStatus']
if status == 200
    puts json['responseData']['translatedText']
else
    puts "(#{responseStatus}) erro ao traduzir #{word}"
end
Displaying all 2 Code