/** * function to get city weather details * from city name using openweathermap API * @param string $city_name * @return array */ function getCityWeather($city_name) { $url = "http://api.openweathermap.org/data/2.5/weather?q=" . $city_name . "&APPID=" . OPENWEATHERMAP_API_KEY; $api_response = json_decode(curl_URL_call($url), true); $return_array = array('icon' => "http://openweathermap.org/img/w/" . trim($api_response['weather'][0]['icon']) . ".png", 'humidity' => (double) $api_response['main']['humidity'], 'temprature' => (double) $api_response['main']['temp'] - 273.15, 'description' => trim($api_response['weather'][0]['description'])); return $return_array; }
<?php $static_categories = array(0 => "Drama", 1 => "Comedy", 2 => "Musical", 3 => "Satire", 4 => "Romantic", 5 => "Poetry", 6 => "Monologue", 7 => "Guided Tours", 8 => "Photography", 9 => "Workshop", 10 => "Stand-Up", 11 => "Dance", 12 => "Convention", 13 => "Workshops", 14 => "Live Show", 15 => "Pop", 16 => "Education", 17 => "Food", 18 => "Talks", 19 => "Entertainment", 20 => "Gaming", 21 => "History", 22 => "Musical Comedy", 23 => "Food Festivals", 24 => "Indian Music", 25 => "Sufi", 26 => "Family", 27 => "Indian Classical", 28 => "Adventure", 29 => "Bollywood", 30 => "International Music", 31 => "Rock", 32 => "Tennis", 33 => "Marathon", 34 => "Fitness", 35 => "Motorsports", 36 => "Sports"); require 'inc/curl_call.php'; require 'inc/connection.inc.php'; $url_categories = ['PL', 'CT', 'SP']; // $categories = array(); $count = 0; foreach ($url_categories as $url_category) { $url = 'http://in.bookmyshow.com/getJSData/?cmd=GETEVENTLIST&f=json&et=' . $url_category . '&rc=NCR&t=67x1xa33b4x422b361ba&sr=<=&lg='; $json_response = curl_URL_call($url); $json_response = json_decode($json_response, true); $json_response = $json_response['BookMyShow']; foreach ($json_response['arrEvent'] as $event) { if ($event['arrVenues'][0]['RegionCode'] != 'NCR') { continue; } $event_name = trim(str_replace("'", "", $event['EventTitle'])); $event_description = htmlspecialchars(trim($event['EventSynopsis']), ENT_QUOTES); $category_array = $event['GenreArray']; $date = (int) $event['arrDates'][0]['ShowDateCode']; $date_year = (int) ($date / 10000); $date = $date % 10000; $date_month = (int) ($date / 100); $date = $date % 100; $date = $date_year . "-" . $date_month . "-" . $date; $date = getTimestamp(strtotime($date)); $lat = (double) $event['arrVenues'][0]['VenueLatitude']; $lng = (double) $event['arrVenues'][0]['VenueLongitude']; $venueName = $event['arrVenues'][0]['VenueName']; $image = $event['BannerURL'];
} } $parts = explode('/', $css_route); $parts_length = sizeof($parts); $css_root = $parts[0] . '//' . $parts[2]; $css_active_dir = $css_root; $css_parent_dir = $css_root; for ($i = 3; $i < $parts_length - 1; ++$i) { if ($i < $parts_length - 2) { $css_active_dir = $css_active_dir . '/' . $parts[$i]; $css_parent_dir = $css_parent_dir . '/' . $parts[$i]; } else { $css_active_dir = $css_active_dir . '/' . $parts[$i]; } } $css = curl_URL_call($css_route); $matches = array(); /** * Getting image urls using image extension matches in stylesheet extracted */ preg_match_all('/url\\(\\s*[\'"]?(\\S*\\.(?:jpe?g|gif|png))[\'"]?\\s*\\)[^;}]*?/i', $css, $matches); foreach ($matches[1] as $image_link) { /** * check whether the URL in the $image_link is absolute or relative * if it is relative, make it absolute */ if ($image_link[0] == '.' && $image_link[1] == '.') { $image_link = $css_parent_dir . substr($image_link, 2); } else { if ($image_link[0] == '.') { $image_link = $css_active_dir . substr($image_link, 1);
<?php /** * @Author: Prabhakar Gupta * @Date: 2016-02-08 12:40:23 * @Last Modified by: Prabhakar Gupta * @Last Modified time: 2016-02-08 13:02:24 */ require_once '../inc/connection.inc.php'; require_once '../inc/function.inc.php'; $url = return_base_URL() . "current_level.php"; $current_move_number = json_decode(curl_URL_call($url), true); $current_move_number = (int) $current_move_number['level']; if (isset($_GET['user_id'])) { $user_id = (int) $_GET['user_id']; $query = "SELECT `loan_amount` FROM `user_loan_log` WHERE `user_id`='{$user_id}' AND `returned`=0"; $query_row = mysqli_fetch_assoc(mysqli_query($connection, $query)); $loan_amount = $query_row['loan_amount']; if (isset($loan_amount)) { $update_query = "UPDATE `user_loan_log` L, `users` U SET L.returned = 1, U.money = U.money - '{$loan_amount}' WHERE L.user_id = U.user_id AND L.returned = 0 AND U.user_id = '{$user_id}'"; if (mysqli_query($connection, $update_query)) { $success = true; } else { $success = false; } } else { // this means there are no outstanding loans // for this user_id $success = false; } }
* @Date: 2016-03-18 23:13:45 * @Last Modified by: Prabhakar Gupta * @Last Modified time: 2016-03-19 01:54:51 */ require_once '../../inc/connection.inc.php'; require_once '../../inc/constants.inc.php'; require_once '../../inc/function.inc.php'; require_once 'lib/twitteroauth.php'; $city_id = @(int) $_GET['city']; $yahoo_url = "http://where.yahooapis.com/v1/places"; if ($city_id > 0) { $city_name = getCityName($connection, $city_id); if (isset($city_name)) { $city_name = trim($city_name['city_name']); $url = $yahoo_url . ".q('" . $city_name . "')?appid=" . YAHOO_WOEID_KEY; $response = curl_URL_call($url); $xml = simplexml_load_string($response); $woeid_city1 = (int) $xml->place->woeid; $xml = $xml->place->admin1; foreach ($xml->attributes() as $a => $b) { if ($a == "woeid") { $woeid_city2 = (int) $b; break; } } $twitter_connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_OAUTH_TOKEN, TWITTER_OAUTH_TOKEN_SECRET); $response = $twitter_connection->get("https://api.twitter.com/1.1/trends/place.json?id=" . $woeid_city1); if (isset($response->errors)) { $response = $twitter_connection->get("https://api.twitter.com/1.1/trends/place.json?id=" . $woeid_city2); } if (isset($response->errors)) {
<?php require 'inc/connection.inc.php'; require 'inc/function.inc.php'; require_once 'inc/constants.inc.php'; $url = 'http://developer.echonest.com/api/v4/song/search?api_key=' . ECHONEST_API_KEY . '&format=json&results=1&bucket=audio_summary&'; if (isset($_GET['artist']) && isset($_GET['song']) && isset($_GET['userid'])) { $user_id = (int) $_GET['userid']; $artist_name = urlencode(trim(strtolower($_GET['artist']))); $song_title = urlencode(trim(strtolower($_GET['song']))); $url .= 'artist=' . $artist_name . '&title=' . $song_title; $json_response = json_decode(curl_URL_call($url), true); $mood_score = (double) $json_response['response']['songs'][0]['audio_summary']['energy']; $update_flag = false; if ($mood_score >= 0.6) { $query = "UPDATE `users` SET `mood` = `mood` + 1 WHERE `id`='{$user_id}' "; $update_flag = true; } else { if ($mood_score <= 0.4 && $mood_score > 0) { $query = "UPDATE `users` SET `mood` = `mood` - 1 WHERE `id`='{$user_id}'"; $update_flag = true; } } if ($update_flag) { mysqli_query($connection, $query); } $query = "SELECT `mood` FROM `users` WHERE `id`='{$user_id}' LIMIT 1"; $query_row = mysqli_fetch_assoc(mysqli_query($connection, $query)); $mood_score = (int) $query_row['mood']; echo json_encode(array('mood' => $mood_score)); }
<?php require 'inc/connection.inc.php'; require 'inc/function.inc.php'; $redbus_url = "https://mobapi.redbus.in/wdsvc/v1_1/bussearch"; // ?fromCityId=1443&toCityId=733&doj=25-Mar-2016 $final_response = array(); if (isset($_GET['src']) && isset($_GET['dest']) && isset($_GET['date'])) { // source city name string $source_city_name = trim($_GET['src']); // destination city name string $destination_city_name = trim($_GET['dest']); // timestamp to be searched in seconds $timestamp_to_be_searched = (int) $_GET['date']; $date_string = date("j-M-Y", $timestamp_to_be_searched); $cities_json = json_decode(file_get_contents('res/redbus-cities.json'), true); $soruce_redbus_id = array_search(strtolower($source_city_name), array_map('strtolower', $cities_json)); $destination_redbus_id = array_search(strtolower($destination_city_name), array_map('strtolower', $cities_json)); $redbus_url = $redbus_url . '?fromCityId=' . $soruce_redbus_id . '&toCityId=' . $destination_redbus_id . '&doj=' . $date_string; $redbus_response = json_decode(curl_URL_call($redbus_url), true); foreach ($redbus_response['data'] as $plan) { $temp_array = array('name' => $plan['serviceName'], 'type' => $plan['BsTp'], 'is_AC' => (bool) $plan['IsAc'], 'owner' => $plan['Tvs'], 'contact' => $plan['BPLst'][0]['BpContactNo'], 'dep_add' => $plan['BPLst'][0]['BpAddress'], 'fair' => $plan['FrLst'][0]); array_push($final_response, $temp_array); } $temp_array = array('name' => 'Suryansh Bus travels and NON-AC', 'type' => 'Non A/C Seater/Sleeper (2+1)', 'is_AC' => (bool) 0, 'owner' => 'suryansh Travels', 'contact' => '+91 - 8860870822', 'dep_add' => 'Rajesh mandi, Pranav road', 'fair' => 2100); array_push($final_response, $temp_array); } echo json_encode(array('results' => $final_response));
<?php require 'inc/connection.inc.php'; require 'inc/functions.inc.php'; if (!isset($_GET['user']) || !isset($_GET['project'])) { echo 'aloo'; } else { $user_id = (int) $_GET['user']; $project_id = (int) $_GET['project']; curl_URL_call($DOMAIN_NAME . 'increase-priority.php?user='******'&project=' . $project_id . '&score=3'); $query = "INSERT INTO `following` (`user_id` , `project_id`) VALUES ('{$user_id}','{$project_id}')"; if (mysqli_query($connection, $query)) { echo 1; } else { echo 0; } }
function duckduckgoreturn($keyword) { $search_url = "http://api.duckduckgo.com/?q=" . str_replace(" ", "+", $keyword) . "&format=json&pretty=1"; $json_results = json_decode(curl_URL_call($search_url), true); return $json_results['AbstractText']; }
<?php require 'inc/connection.inc.php'; require 'inc/function.inc.php'; $train_api_code = "ffhzn9117"; $final_response = array(); if (isset($_GET['src_city']) && isset($_GET['dest_city']) && isset($_GET['date'])) { $source = strtolower(trim($_GET['src_city'])); $destination = strtolower(trim($_GET['dest_city'])); $src_url = 'http://api.railwayapi.com/name_to_code/station/' . $source . '/apikey/' . $train_api_code . '/'; $response = json_decode(curl_URL_call($src_url), true); $src_code = $response['stations'][0]['code']; $dest_url = 'http://api.railwayapi.com/name_to_code/station/' . $destination . '/apikey/' . $train_api_code . '/'; $response = json_decode(curl_URL_call($dest_url), true); $dest_code = $response['stations'][0]['code']; $trains_url = 'http://api.railwayapi.com/between/source/' . $src_code . '/dest/' . $dest_code . '/date/' . $_GET['date'] . '/apikey/' . $train_api_code . '/'; $response = json_decode(curl_URL_call($trains_url), true); foreach ($response['train'] as $train) { $temp_array = array('train_number' => $train['number'], 'name' => $train['name'], 'departure_time' => $train['src_departure_time'], 'arrival_time' => $train['dest_arrival_time']); $temp_array['days'] = array(); foreach ($train['days'] as $day) { if (strtolower($day['runs']) == 'y') { array_push($temp_array['days'], 1); } else { array_push($temp_array['days'], 0); } } array_push($final_response, $temp_array); } } echo json_encode(array('trains' => $final_response));
if ($place_website == "") { $place_website = $response_place['result']['url']; } $place_array = array("name" => trim($response_place['result']['name']), "address" => trim($response_place['result']['vicinity']), "contact" => trim($response_place['result']['international_phone_number']), "latitude" => (double) $response_place['result']['geometry']['location']['lat'], "longitude" => (double) $response_place['result']['geometry']['location']['lng'], "website" => $place_website == "" ? null : trim($place_website)); array_push($shopping_response, $place_array); } //lodging $url_init = 'https://maps.googleapis.com/maps/api/place/radarsearch/json?location=' . $lat . ',' . $lng . '&radius=5000&types=lodging&key=' . $google_maps_api_key; $response = curl_URL_call($url_init); $response = json_decode($response, true); $count = 0; foreach ($response['results'] as $place) { $count++; if ($count >= 4) { break; } $placeID = $place['place_id']; $url_finl = "https://maps.googleapis.com/maps/api/place/details/json?placeid=" . $placeID . "&key=" . $google_maps_api_key; $response_place = curl_URL_call($url_finl); $response_place = json_decode($response_place, true); $place_website = $response_place['result']['website']; if ($place_website == "") { $place_website = $response_place['result']['url']; } $place_array = array("name" => trim($response_place['result']['name']), "address" => trim($response_place['result']['vicinity']), "contact" => trim($response_place['result']['international_phone_number']), "latitude" => (double) $response_place['result']['geometry']['location']['lat'], "longitude" => (double) $response_place['result']['geometry']['location']['lng'], "website" => $place_website == "" ? null : trim($place_website)); array_push($hotels_response, $place_array); } } $final_response = array("long_description" => $long_description, "category" => $event_categories, "venue" => $venue, "link" => $link, "hotels" => $hotels_response, "shopping" => $shopping_response, "art_gallery" => $art_gallery_response, "restraunt" => $restraunt_response); echo json_encode($final_response); }