public function fetch_search($query, $region)
    {
        $query     = trim($query);
        $url       = 'http://marketplace.xbox.com/' . $region . '/SiteSearch/xbox/?query=' . urlencode($query);
        $key       = $this->version . ':friends.' . $query;
        $data      = $this->__cache->fetch($key);
        $freshness = 'from cache';

        if (!$data) {
            $data      = $this->fetch_url($url);
            $freshness = 'new';
            $this->__cache->store($key, $data, 3600);
        }

        $json = json_decode($data, true);
        if ($json['totalEntries'] >= 1) {
            $search                 = array();
            $search['totalresults'] = $json['totalEntries'];
            $search['resultslink']  = 'http://marketplace.xbox.com' . $json['allResultsUrl'];

            $i = 0;
            foreach ($json['entries'] as $entry) {
                $search['results'][$i]['title']                 = $entry['title'];
                $search['results'][$i]['parent']                = $entry['parentTitle'];
                $search['results'][$i]['link']                  = 'http://marketplace.xbox.com' . $entry['detailsUrl'];
                $search['results'][$i]['image']                 = $entry['image'];
                $search['results'][$i]['downloadtype']['class'] = $entry['downloadTypeClass'];
                $search['results'][$i]['downloadtype']['title'] = $entry['downloadTypeText'];
                $search['results'][$i]['prices']['silver']      = $entry['prices']['silver'];
                $search['results'][$i]['prices']['gold']        = $entry['prices']['gold'];
                $i++;
            }

            $search['freshness'] = $freshness;
            return $search;
        } else {
            $this->error = 504;
            $this->__cache->remove($key);
            return false;
        }
    }
public function fetch_search($query, $region)
    {
        $query     = trim($query);
        $url       = 'http://marketplace.xbox.com/' . $region . '/SiteSearch/xbox/?query=' . urlencode($query);
        $key       = $this->version . ':friends.' . $query;
        $data      = $this->__cache->fetch($key);
        $freshness = 'from cache';

        if (!$data) {
            $data      = $this->fetch_url($url);
            $freshness = 'new';
            $this->__cache->store($key, $data, 3600);
        }

        $json = json_decode($data, true);
        if ($json['totalEntries'] >= 1) {
            $search                 = array();
            $search['totalresults'] = $json['totalEntries'];
            $search['resultslink']  = 'http://marketplace.xbox.com' . $json['allResultsUrl'];

            $i = 0;
            foreach ($json['entries'] as $entry) {
                $search['results'][$i]['title']                 = $entry['title'];
                $search['results'][$i]['parent']                = $entry['parentTitle'];
                $search['results'][$i]['link']                  = 'http://marketplace.xbox.com' . $entry['detailsUrl'];
                $search['results'][$i]['image']                 = $entry['image'];
                $search['results'][$i]['downloadtype']['class'] = $entry['downloadTypeClass'];
                $search['results'][$i]['downloadtype']['title'] = $entry['downloadTypeText'];
                $search['results'][$i]['prices']['silver']      = $entry['prices']['silver'];
                $search['results'][$i]['prices']['gold']        = $entry['prices']['gold'];
                $i++;
            }

            $search['freshness'] = $freshness;
            return $search;
        } else {
            $this->error = 504;
            $this->__cache->remove($key);
            return false;
        }
    }
public function fetch_search ( $ query , $ region ) { $ query = trim ( $ query ) ; $ url = 'http://marketplace.xbox.com/' . $ region . '/SiteSearch/xbox/?query=' . urlencode ( $ query ) ; $ key = $ this -> version . ':friends.' . $ query ; $ data = $ this -> __cache -> fetch ( $ key ) ; $ freshness = 'from cache' ; if ( ! $ data ) { $ data = $ this -> fetch_url ( $ url ) ; $ freshness = 'new' ; $ this -> __cache -> store ( $ key , $ data , 3600 ) ; } $ json = json_decode ( $ data , true ) ; if ( $ json [ 'totalEntries' ] >= 1 ) { $ search = array ( ) ; $ search [ 'totalresults' ] = $ json [ 'totalEntries' ] ; $ search [ 'resultslink' ] = 'http://marketplace.xbox.com' . $ json [ 'allResultsUrl' ] ; $ i = 0 ; foreach ( $ json [ 'entries' ] as $ entry ) { $ search [ 'results' ] [ $ i ] [ 'title' ] = $ entry [ 'title' ] ; $ search [ 'results' ] [ $ i ] [ 'parent' ] = $ entry [ 'parentTitle' ] ; $ search [ 'results' ] [ $ i ] [ 'link' ] = 'http://marketplace.xbox.com' . $ entry [ 'detailsUrl' ] ; $ search [ 'results' ] [ $ i ] [ 'image' ] = $ entry [ 'image' ] ; $ search [ 'results' ] [ $ i ] [ 'downloadtype' ] [ 'class' ] = $ entry [ 'downloadTypeClass' ] ; $ search [ 'results' ] [ $ i ] [ 'downloadtype' ] [ 'title' ] = $ entry [ 'downloadTypeText' ] ; $ search [ 'results' ] [ $ i ] [ 'prices' ] [ 'silver' ] = $ entry [ 'prices' ] [ 'silver' ] ; $ search [ 'results' ] [ $ i ] [ 'prices' ] [ 'gold' ] = $ entry [ 'prices' ] [ 'gold' ] ; $ i ++ ; } $ search [ 'freshness' ] = $ freshness ; return $ search ; } else { $ this -> error = 504 ; $ this -> __cache -> remove ( $ key ) ; return false ; } }
Fetch data for a search query

@access public
@var    string $query
@var    string $region
@return array
Fetch data for a search query