- $url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=0&rsz=8&hl=th&q=";
- $q = urlencode("วาล์วกันกลับ");
- // sendRequest
- // note how referer is set manually
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url.$q);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- //curl_setopt($ch, CURLOPT_REFERER, "http://www.scivalve.com");
- $body = curl_exec($ch);
- curl_close($ch);
- // now, process the JSON string
- $json = json_decode($body, true);
- // now have some fun with the results...
- foreach ($json as $item)
- {
- //var_dump($item);
- //echo "<hr>";
- if(is_array($item))
- foreach ($item["results"] as $result)
- {
- echo "<hr>";
- var_dump($result);
- }
- }
https://developers.google.com/web-search/docs/?hl=en
ไม่มีความคิดเห็น:
แสดงความคิดเห็น