Example #1
0
function perform_google_web_search_single($termstring)
{
    $start = 0;
    $get_google_API = ot_get_option('ktz_googleapi_key');
    $result = array();
    while ($start < 4) {
        $searchurl = 'http://ajax.googleapis.com/ajax/services/search/images?v=1.0';
        $searchurl .= '&key=' . $get_google_API;
        $searchurl .= '&start=' . $start;
        $searchurl .= '&rsz=large';
        $searchurl .= '&filter=0';
        $searchurl .= '&q=' . urlencode($termstring);
        $response = pete_curl_get($searchurl, array());
        $responseobject = json_decode($response, true);
        if (count(isset($responseobject['responseData']['results'])) == 0) {
            break;
        }
        $allresponseresults = $responseobject['responseData']['results'];
        if (is_array($allresponseresults)) {
            foreach ($allresponseresults as $responseresult) {
                $result[] = array('url' => $responseresult['url'], 'title' => $responseresult['title'], 'thumbnail' => $responseresult['tbUrl'], 'height' => $responseresult['tbHeight'], 'width' => $responseresult['tbWidth'], 'abstract' => $responseresult['content'], 'Oriurl' => $responseresult['url']);
            }
        } else {
            echo '';
        }
        $start += 2;
    }
    return $result;
}
Example #2
0
function perform_bing_web_search($termstring)







{







$searchurl = 'http://api.bing.net/json.aspx?';







$searchurl .= 'AppId='.'76371219B642AE50E43D37DA9098F09CD0FBDC39';







$searchurl .= '&Query='.urlencode($termstring);







$searchurl .= '&Sources=Web';







$searchurl .= '&Web.Count=5';







$searchurl .= '&Web.Offset=0';







$searchurl .= '&Web.Options=DisableHostCollapsing+DisableQueryAlterations';







$searchurl .= '&JsonType=raw';







$response = pete_curl_get($searchurl, array());







$responseobject = json_decode($response, true);







if ($responseobject['SearchResponse']['Web']['Total']==0)







return array();







$allresponseresults = $responseobject['SearchResponse']['Web']['Results'];







$result = array();







foreach ($allresponseresults as $responseresult)







{







$result[] = array(







'url' => $responseresult['Url'],







'title' => $responseresult['Title'],







'abstract' => $responseresult['Description'],







);







}







return $result;







}