} if (!$output) { $output = 'php'; } if (!$eventInput) { $eventDataURL = 'http://prod1.yrb.scd.yahoo.com/8rlv2l5An3TL2Qs/happenings/eventInfo.php?eventid=' . $eventid; if ($debug == 1) { echo $eventDataURL; } $eventDetails = unserialize(downloadURL($eventDataURL)); } else { $eventInput = htmlspecialchars_decode($eventInput); $eventDetails = unserialize($eventInput); } if ($debug == 1) { show_keys($eventDetails); } $eventName = $eventDetails['event']['name']; $eventDate = $eventDetails['event']['start_date']; $eventVenue = $eventDetails['event']['venue_name']; $eventCity = $eventDetails['event']['venue_city']; $eventDescription = $eventDetails['event']['description']; $eventArtists = $eventDetails['event']['artists']; //get the youtube videos of the event foreach ($eventArtists as $artist) { $page = 1; $youtubeBaseURL = "http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=BTcmAmlosuY&page={$page}&per_page=100&tag="; $videoList = returnParsedXML($youtubeBaseURL . urlencode($artist . ' ' . $eventCity)); if ($debug == 1) { echo $youtubeBaseURL . urlencode($artist . ' ' . $eventCity) . '<br>'; }
$keywords[] = 'music'; $keywords[] = 'show'; $keywords[] = 'band'; //$XMLbody .= '<keywords>' . array_to_xmlCD($keywords, 2) . '</keywords>'; $outputArray['keyword'] = $keywords; //show_keys($outputArray); /*$XMLbody = '<?xml version="1.0"?><rsp stat="ok"><event>' . $XMLbody . '</event></rsp>';*/ // } else { /*$XMLbody = '<?xml version="1.0" encoding="ISO-8859-1"?><rsp stat="fail"><err code="1" msg="Invalid usertoken" /> </rsp>';*/ } $output = array(); $output['event'] = $outputArray; echo serialize($output); if ($debug == 1) { show_keys($output); } //displayXML($XMLbody); die; //function to download and parse an XML document given a URL function returnParsedXMLPost($docURL, $postVars) { $url = $docURL; $user_agent = "Mozilla/5.0 (Macintosh; U; PPC Mac OSX; en-us)"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
function show_keys($ar) { echo "<table width='100%' border='1' bordercolor='#6699CC' cellspacing='0' cellpadding='5'><tr valign='top'>"; foreach ($ar as $k => $v) { echo "<td align='center' bgcolor='#EEEEEE'>\r\n\t <table border='2' cellpadding='3'><tr><td bgcolor='#FFFFFF'><font face='verdana' size='1'>\r\n\t\t " . $v . "(" . $k . ")\r\n\t </font></td></tr></table>"; if (is_array($ar[$k])) { show_keys($ar[$k]); } echo "</td>"; } echo "</tr></table>"; }
function getLocationCoordinates($locationString, $server = 'geo.intl.yahoo.com', $port = 4080, $path = '/RPC2', $username = '******', $password = '******') { global $commondir; global $debug; include_once $commondir . 'xmlrpc-2.2/lib/xmlrpc.inc'; include_once $commondir . "utf8_to_ascii/utf8_to_ascii.php"; $client = new xmlrpc_client($path, $server, $port); $client->setCredentials('research', 'severn'); $msg = new xmlrpcmsg('locationprobability.calculate', array(new xmlrpcval("any id", "string"), new xmlrpcval($locationString, "string"))); //print "<pre>Sending the following request:\n\n" . htmlentities($msg->serialize()) . "\n\nDebug info of server data follows...\n\n</pre>"; $resp =& $client->send($msg); if (!$resp->faultCode()) { //print "value: <pre>" . htmlspecialchars($resp->serialize()) . '</pre>'; $value = $resp->value(); $phpval = php_xmlrpc_decode($value); //show_keys($phpval); $result = $phpval['contents']['0']; if (!$result) { return false; } if ($debug == 1) { show_keys($result); } $returnCoordinates['name'] = $result['name']; $returnCoordinates['type'] = $result['placetypename']; $returnCoordinates['city'] = $result['posttown']; $returnCoordinates['state'] = $result['state']; $returnCoordinates['country'] = $result['country']; $returnCoordinates['zipcode'] = $result['zip']; $returnCoordinates['latitude'] = $result['centroid']['latitude']; $returnCoordinates['longitude'] = $result['centroid']['longitude']; $returnCoordinates['startLat'] = $result['box']['swcorner']['latitude']; $returnCoordinates['endLat'] = $result['box']['necorner']['latitude']; $returnCoordinates['startLong'] = $result['box']['swcorner']['longitude']; $returnCoordinates['endLong'] = $result['box']['necorner']['longitude']; //show_keys($returnCoordinates); return $returnCoordinates; } else { //print "value: <pre>" . htmlspecialchars($resp->faultCode()) . '</pre>'; //echo($resp->faultCode()); } return false; }