13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.130 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.1313:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.13

.

.

Saturday, November 12, 2011

PHP Functions - gr17gr17

<?php
function parseTwitterReply($messages){
$twitterReturn = new SimpleXMLElement($messages);
$i=0;
foreach($twitterReturn->status as $status){
$updateTime[$i]=$status->created_at;
$update[$i]=$status->text;
$profile_image_url[$i] = $status->user->profile_image_url;
$screen_name[$i] = $status->user->screen_name;
$i++;
}
$parsedReturn = array();
$parsedReturn['updateTime']=$updateTime;
$parsedReturn['update']=$update;
$parsedReturn['profile_image_url']=$profile_image_url;
$parsedReturn['screen_name']=$screen_name;

return $parsedReturn;

}

function call_timeline($messages) {
$twitterReturn = new SimpleXMLElement($messages);
$i=0;
foreach($twitterReturn->status as $status) {
$updateTime[$i] = parseDate($status->created_at);
$update[$i] = $status->text;
$profile_image_url[$i] = $status->user->profile_image_url;
$screen_name[$i] = $status->user->screen_name;
    $i++;
}
$parsedReturn = array();
$parsedReturn['updateTime']=$updateTime;
$parsedReturn['update']=$update;
$parsedReturn['profile_image_url']=$profile_image_url;
$parsedReturn['screen_name']=$screen_name;
return $parsedReturn;
}


function getTwitterData($command) {
global $twitter;
switch ($command) {
case 'timeline':
    { $messages=$twitter->getHomeTimeline('xml');
    return call_timeline($messages);
    }
             break;
case 'mentions':
    { $messages=$twitter->getMentions('xml');
    return call_timeline($messages);
    }
             break;
case 'direct':
    { $messages=$twitter->getMessages('xml');
    return call_direct($messages);
    }
    break;
  }
  function getHomeTimeline($format, $id=NULL, $count = 60, $since = NULL) {
    if ($id != NULL) {
      $api_call = sprintf("statuses/home_timeline/%s.%s", $id, $format);
         }
    else {
      $api_call = sprintf("statuses/home_timeline.%s", $format);
         }
    if ($since != NULL) {
      $api_call .= sprintf("?since_id=%s", urlencode($since));
      $count=0;
        }
    if ($count != 60 AND $count !='') {
      $api_call .= sprintf("?count=%d", $count);
        }
    return $this->get($api_call);
    }
 }



?>