Skip to content

Instantly share code, notes, and snippets.

@wrilben
Last active August 12, 2019 01:12
Show Gist options
  • Save wrilben/eaf73d4a7d7e435b5e05ce0c43f31a07 to your computer and use it in GitHub Desktop.
Save wrilben/eaf73d4a7d7e435b5e05ce0c43f31a07 to your computer and use it in GitHub Desktop.
Aggregate Events from Facebook, Eventbrite, Meetup and other platforms using a geo-location
<?php
// Generate geo location using Ip Address
$user_ip = 'getenv('REMOTE_ADDR')';
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$country = $geo["geoplugin_countryName"];
$city = $geo["geoplugin_city"];
$lgn = $geo['geoplugin_longitude'];
$lat = $geo['geoplugin_latitude'];
function eventbrite_aggregate ($ev_loc) {
$xml = file_get_contents("https://www.eventbriteapi.com/v3/events/search/?token=EJSVQV32J3UDY7ALBDXP&location.address=$ev_loc");
$characters = json_decode($xml);
$xmls = $characters->events;
foreach ($xmls as $key => $jsons) {
foreach($jsons as $key => $value) {
if ($key == 'name') {
$arr['name'] = $value -> html;
}
if ($key == 'description') {
$arr['description'] = $value -> html;
}
if ($key == 'logo') {
if($value != ''){
$arr['logo'] = $value -> url;
}
}
if ($key == 'start') {
if ($value != '') {
$arr['start_local'] = $value -> local;
$arr['start_timezone'] = $value -> timezone;
}
}
}
}
print_r($arr);
}
function meetup_aggregate () {
$xml = file_get_contents("http://api.meetup.com/find/events?topic=web&lon=-0.196306&lat=5.555717&key=182c2f69a3c49322a3c371d1c4c16c");
$xmls = json_decode($xml);
foreach ($xmls as $key => $jsons) {
foreach($jsons as $key => $value) {
if ($key == 'name') {
$arr['name'] = $value;
}
if ($key == 'description') {
$arr['description'] = $value;
}
if ($key == 'time') {
$arr['time'] = $value;
}
}
}
print_r($arr);
}
function artists_events_aggregate ($ev_loc) {
$xml = file_get_contents('https://rest.bandsintown.com/artists/'.$ev_loc.'/events?app_id=Ventsell');
$xmls = json_decode($xml);
foreach ($xmls as $key => $jsons) {
foreach ($jsons as $key => $value) {
if ($key == 'datetime') {
$arr['datetime'] = $value;
}
if ($key == 'venue') {
$arr['name'] = $value -> name;
$arr['city'] = $value -> city;
$arr['country'] = $value -> country;
$arr['latitude'] = $value -> latitude;
$arr['longitude'] = $value -> longitude;
}
}
}
print_r($arr);
}
function artists_aggregate ($ev_loc) {
$xml = file_get_contents('https://rest.bandsintown.com/artists/'.$ev_loc.'?app_id=Ventsell');
$xmls = json_decode($xml);
foreach ($xmls as $key => $value) {
if ($key == 'name') {
$arr['Name'] = $value;
}
if ($key == 'image_url') {
$arr['imageUrl'] = $value;
}
if ($key == 'facebook_page_url') {
$arr['facebookPageUrl'] = $value;
}
if ($key == 'tracker_count') {
$arr['trackerCount'] = $value;
}
if ($key == 'upcoming_event_count') {
$arr['upcomingEventCount'] = $value;
}
}
print_r($arr);
}
function facebook_aggregate ($a ,$b) {
$xml = file_get_contents("https://ventsell.com/facebook?lat=$a&lng=$b&distance=1000000&sort=venue&access_token=1874180662805544|x8LO4bxiM9UStK7TJpbZAruBBZA");
$characters = json_decode($xml);
$xmls = $characters->events;
foreach ($xmls as $key => $jsons) {
foreach($jsons as $key => $value) {
if ($key == 'eventName') {
$arr['eventName'] = $value;
}
if ($key == 'eventCoverPicture') {
$arr['coverPicture'] = $value;
}
if ($key == 'eventDescription') {
$arr['eventDescription'] = $value;
}
if ($key == 'venueName') {
$arr['venueName'] = $value;
}
if ($key == 'eventStarttime') {
$arr['eventStarttime'] = $value;
}
}
}
print_r($arr);
}
function eventful_now() {
$xml = file_get_contents("http://api.eventful.com/json/events/search?app_key=zFL8jBPTxHq7HHpN&location=Ghana&date=Future");
$characters = json_decode($xml);
$xmls = $characters->events -> event;
foreach ($xmls as $key => $jsons) {
foreach($jsons as $key => $value) {
if ($key == 'title') {
$arr['title'] = $value;
}
}
}
print_r($arr);
}
// Call method and pass in appropriate information //
facebook_aggregate('5.6037168' ,'-0.1869644');
eventbrite_aggregate('Ghana');
meetup_aggregate();
meetup_aggregate('gh');
artists_events_aggregate('Adele');
eventbrite_aggregate('London');
artists_aggregate('Jay Z');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment