July 10, 2012

Fetch your tweets with PHP

Fetch your tweets with PHP PHP Function: Filename: tweets_code.php function tweets() { $q=’phpFlex’; $tweets = file_get_contents(‘http://search.twitter.com/search.json?q=’.$q.’&rpp=2&include_entities=false&with_twitter_user_id=true&result_type=recent’); $tweets_obj = json_decode($tweets); $return = array(); if(count($tweets_obj)>0) { if(isset($tweets_obj->results) && count($tweets_obj->results)>0) { foreach($tweets_obj->results as $key=>$result) { $return[$key][‘text’] = $result->text; } } } echo json_encode($return); } Javascript Functions:   function get_tweets() { var tweets_url = ‘tweets_code.php’; $.get(tweets_url, function(data) { var […]

January 6, 2012

json parse example

function httpRequest(url,params) { var http = false; if(navigator.appName == “Microsoft Internet Explorer”) { http = new ActiveXObject(“Microsoft.XMLHTTP”); } else { http = new XMLHttpRequest(); } http.open(“POST”, url, true); //Send the proper header information along with the request http.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”); http.setRequestHeader(“Content-length”, params.length); http.setRequestHeader(“Connection”, “Keep-Alive”); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == […]