fuzzygoth: (Fuzzygoth - Air Guitar)
[personal profile] fuzzygoth
Okay, I've posted on forums to no avail and now I am turning on the
gEeK signal on from Livejournal Land. I am currently trying to create
a site search using the google search engine, the only drawback is
I cannot use JavaScript because as a Government Department we need to
provide JavaScript Alternitves.

So looking at the new Ajax Google search its provide an alternitive
using JSON, which so far returns information fine with JavaScript
being turned off. I am using the php Services_JSON.php with php
5.1.2 with wamp and the php_json.dll. I can return the dataset
and decode it with json and even see the info if i do a var_dump.

What I am having problems with is parsing the information, so I
can write it out as a custom style page. I can't get the data out.
I am currently trying to put the object into an array and call it
out that way. It keep returning an error when I try to access it
directly as an array i assume from the error its a object not an
array or some reading of the web says it might be coming through as
an associated array? the error message for trying access the $output;
as an array is below:

Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\GoogleSearch.php on line 18



php

include('Services_JSON.php');

$json = new Services_JSON;

$url = "http://ajax.googleapis.com/ajax/services/search/web?rzs=12&v=1.0&q=DWP%20uk";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://localhost/GoogleSearch.php");
$body = curl_exec($ch);
curl_close($ch);

$output = $json-decode($body);

?>

Date: 2008-11-14 02:17 pm (UTC)
From: [identity profile] stuntpilot99.livejournal.com
Know nothing about google api, but plan B might be to have a look at some of the scripts on top of scroogle.

www.scroogle.org if you don't know it.

I think a couple of people released scripts for it after google deprecated the original api.

Though that might just be a huge distraction.

Profile

fuzzygoth: (Default)
fuzzygoth

December 2011

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 16th, 2025 02:12 pm
Powered by Dreamwidth Studios