Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / get
Created February 25, 2010 17:27
function get($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function get($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
new Request.Twitter('phploveme',{
data: {count: 5},
onSuccess: function(data){
data.each(function(data){
new Element('div',{
class: 'tweet',
html: data.text
}).inject('tweets','bottom');
})
}
Request.Twitter = new Class({
Extends: Request.JSONP,
options: {
url: 'http://twitter.com/statuses/user_timeline/{username}.json',
data: {
count: 5
},
linkify: true
},
Request.Weather = new Class({
Extends: Request.JSONP,
options: {
url: 'http://query.yahooapis.com/v1/public/yql?q=use%20%22http%3A%2F%2Fthinkphp.ro%2Fapps%2FYQL%2Fweather-forecast%2Fweather.woeid.xml%22%20as%20weather%3B%20select%20*%20from%20weather%20where%20location%3D%22{term}%22%20and%20unit%3D%22c%22%3B',
data: {
format: 'json'
}
},
Request.Weather = new Class({
Extends: Request.JSONP,
options: {
url: 'http://query.yahooapis.com/v1/public/yql?q=use%20%22http%3A%2F%2Fthinkphp.ro%2Fapps%2FYQL%2Fweather-forecast%2Fweather.woeid.xml%22%20as%20weather%3B%20select%20*%20from%20weather%20where%20location%3D%22{term}%22%20and%20unit%3D%22{unit}%22%3B',
data: {
format: 'json'
}
},
window.addEvent('domready',function(){
new Request.Weather('bucharest','c',{
onSuccess: function(o){
var title = '<p style="color: blue"><strong>'+o.query.results.weather.rss.channel.item.title+'</strong></p>',
description = o.query.results.weather.rss.channel.item.description;
$('weatherbadge').set('html',title+description);
}
}).send();
});
Request.Flickr = new Class({
Extends: Request.JSONP,
options: {
url: "http://query.yahooapis.com/v1/public/yql?q=use%20'http%3A%2F%2Fthinkphp.ro%2Fapps%2FYQL%2FgetFlickrBy%2520YQLExecute%2Fflickrlist.xml'%20as%20flickr%3B%20%0A%0ASELECT%20*%20%0A%0AFROM%20flickr%20%0A%0AWHERE%20text%3D'{text}'%20AND%20location%3D'{location}'%20AND%20amount%3D{amount}%0A",
data: {
format: 'xml'
}
},
Request.Flickr = new Class({
Extends: Request.JSONP,
options: {
url: "http://query.yahooapis.com/v1/public/yql?q=use%20'http%3A%2F%2Fthinkphp.ro%2Fapps%2FYQL%2FgetFlickrBy%2520YQLExecute%2Fflickrlist.xml'%20as%20flickr%3B%20%0A%0ASELECT%20*%20%0A%0AFROM%20flickr%20%0A%0AWHERE%20text%3D'{text}'%20AND%20location%3D'{location}'%20AND%20amount%3D{amount}%0A",
data: {
format: 'xml'
}
},
Request.Flickr = new Class({
Extends: Request.JSONP,
options: {
url: "http://thinkphp.ro/apps/YQL/getFlickrBy/getFlickrBy.php?user={username}",
data: {
amount: 15,
size: 's',
format: 'json'
}