Example #1
0
     $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
     $offset = offset();
     $relData = $releases->searchbyRageId(isset($_GET['rid']) ? $_GET['rid'] : '-1', isset($_GET['season']) ? $_GET['season'] : '', isset($_GET['ep']) ? $_GET['ep'] : '', $offset, limit(), isset($_GET['q']) ? $_GET['q'] : '', categoryID(), $maxAge);
     addLanguage($relData, $page->settings);
     printOutput($relData, $outputXML, $page, $offset);
     break;
     // Search movie releases.
 // Search movie releases.
 case 'm':
     verifyEmptyParameter('q');
     verifyEmptyParameter('imdbid');
     $maxAge = maxAge();
     $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
     $offset = offset();
     $imdbId = isset($_GET['imdbid']) ? $_GET['imdbid'] : '-1';
     $relData = $releases->searchbyImdbId($imdbId, $offset, limit(), isset($_GET['q']) ? $_GET['q'] : '', categoryID(), $maxAge);
     addCoverURL($relData, function ($release) {
         return Misc::getCoverURL(['type' => 'movies', 'id' => $release['imdbid']]);
     });
     addLanguage($relData, $page->settings);
     printOutput($relData, $outputXML, $page, $offset);
     break;
     // Get NZB.
 // Get NZB.
 case 'g':
     if (!isset($_GET['id'])) {
         showApiError(200, 'Missing parameter (id is required for downloading an NZB)');
     }
     $relData = $releases->getByGuid($_GET['id']);
     if ($relData) {
         header('Location:' . WWW_TOP . '/getnzb?i=' . $uid . '&r=' . $apiKey . '&id=' . $relData['guid'] . (isset($_GET['del']) && $_GET['del'] == '1' ? '&del=1' : ''));
Example #2
0
/**
 * Queries the API by the input values from the user 
 * 
 * @param    $term        The search term to query
 * @param    $location    The location of the business to query
 */
function query_api($term, $location)
{
    $response = json_decode(search($term, $location));
    foreach ($response->businesses as $business) {
        $business_id = $business->id;
        $business_response = json_decode(get_business($business_id), true);
        $id = $business_response['id'];
        $name = $business_response['name'];
        $phone = $business_response['display_phone'];
        $address = $business_response['location']['address'][0];
        $rating = $business_response['rating'];
        #$businessHours=$business_response['']
        #$categories
        $reservationURL = $business_response['reservation_url'];
        $reviewCount = $business_response['review_count'];
        #$price
        $imageUrl = $business_response['image_url'];
        $city = $business_response['location']['city'];
        $postal_code = $business_response['location']['postal_code'];
        $snippet_text = $business_response['snippet_text'];
        $state = $business_response['location']['state_code'];
        $rating_img_url = $business_response['rating_img_url'];
        $rating_img_url_small = $business_response['rating_img_url_small'];
        $url = $business_response['url'];
        addRestaurant($id, $name, $phone, $address, $rating, $reservationURL, $reviewCount, $imageUrl, $city, $postal_code, $snippet_text, $state, $rating_img_url, $rating_img_url_small, $url);
        $categories = $business_response['categories'];
        foreach ($categories as $category) {
            $c1 = $category[0];
            $c2 = $category[1];
            //echo $c1 . ' ' . $c2;
            $cid = categoryID($c1, $c2);
            echo $cid;
            if ($cid < 0) {
                //category does not exist
                addCategory($c1, $c2);
                $cid = lastCategory();
            }
            addRC($id, $cid);
        }
    }
    /*
        print sprintf(
            "%d businesses found, querying business info for the top result \"%s\"\n\n",         
            count($response->businesses),
            $business_id
        );
        
        $response = get_business($business_id);
        
        print sprintf("Result for business \"%s\" found:\n", $business_id);
        print "$response\n";
    */
}