Newsbar Results for given Country

4 views
Skip to first unread message

matrix-design

unread,
Apr 14, 2008, 5:20:51 AM4/14/08
to Google AJAX API
Is there a way to restrict Google Newsbar content to only return pages
for a particular country. We operate a number of community based sites
for locations around Australia (and elsewhere), and want to display
news for (eg.) Warwick (in Queensland, Australia). Unfortunately, we
also end up getting news for Warwick, UK and Warwick, Georgia (US).

jgeerdes [AJAX APIs "Guru"]

unread,
Apr 14, 2008, 6:53:17 AM4/14/08
to Google AJAX API
Have you tried adding Australia to your query? Unfortunately, there's
really no better solution because the AJAX Search API which powers the
NewsBar doesn't really allow you to specify a country to get results
from. If adding that to you query doesn't help, you might try the
Feeds API's various options. You could plug in feeds from specific
news agencies that cover the areas in question.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com

If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!

matrix-design

unread,
Apr 14, 2008, 8:23:08 PM4/14/08
to Google AJAX API
Thanks for the advice, I'll checkout the RSS feeds options and see if
this solves our problems.


On Apr 14, 8:53 pm, "jgeerdes [AJAX APIs \"Guru\"]"
<jgeer...@mchsi.com> wrote:
> Have you tried adding Australia to your query? Unfortunately, there's
> really no better solution because the AJAX Search API which powers the
> NewsBar doesn't really allow you to specify a country to get results
> from. If adding that to you query doesn't help, you might try the
> Feeds API's various options. You could plug in feeds from specific
> news agencies that cover the areas in question.
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> jgeer...@mchsi.com

mhl

unread,
Apr 15, 2008, 9:05:13 AM4/15/08
to Google AJAX API
Try this:

x = new GSnewsBar();
x.setRestriction(GSearch.RESTRICT_EXTENDED_ARGS, {"geo":"australia"});

We are still working on some of the specifics on the allowable values
for the geo restriction, but simple place names are definitely
supported (we are working on lat/lng geo restricts). By running the
above sequence, your newsbar is scoped to a location, in this case,
Australia.

matrix-design

unread,
Apr 16, 2008, 9:00:37 PM4/16/08
to Google AJAX API
I don't seem to be able to get this to work. The code I'm using is:


function LoadNewsBar() {
var newsBar;
var options = {
linkTarget : GSearch.LINK_TARGET_BLANK,
largeResultSet : false,
title : "Google News",
horizontal : false,
autoExecuteList : {
executeList : ["Warwick", "Australia", "World"]
}
}

newsBar = new GSnewsBar(document.getElementById("newsBar-bar"),
options);
newsBar.setRestriction(GSearch.RESTRICT_EXTENDED_ARGS,
{"geo":"australia"});
}
GSearch.setOnLoadCallback(LoadNewsBar);


This works fine... except the news items returned for "Warwick" is
(today) all UK news items - identical to the data returned when the
"setRestriction" option is removed.

What am I doing wrong?

matrix-design

unread,
Apr 16, 2008, 9:05:54 PM4/16/08
to Google AJAX API
A quick update. I'm getting an error "setRestriction is not a
function". Is there a new/updated javascript file I should be
referencing in my code - the current details are based on the code
generated by the NewsBar wizard... which doesn't mention this new
function in any of the API doco.

Thanks in advance.


On Apr 15, 11:05 pm, mhl <mhl...@gmail.com> wrote:

jgeerdes [AJAX APIs "Guru"]

unread,
Apr 16, 2008, 9:42:22 PM4/16/08
to Google AJAX API
Try this:

x.ns.setRestriction(...);

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com

jgeerdes [AJAX APIs "Guru"]

unread,
Apr 16, 2008, 9:44:57 PM4/16/08
to Google AJAX API
Sorry. Make that newsBar.ns.setRestriction(...); It's too late to be
thinking. :)

jg

matrix-design

unread,
Apr 17, 2008, 10:06:03 PM4/17/08
to Google AJAX API
Thanks... that fixes the javascript error. Still some strange things
happening with the results restriction though. If you have a look at
http://coastalleader.ezyzine.com/ the newsbar (right hand panel on the
site - below the ads) has links for "Kingston" (in South Australia),
"Australia" and "World". The initial news results are for Kingston,
and do not appear filtered. If however, you click on the Australia &
World links and then back to "Kingston" the results start to get
filtered to include Australian sites only (note - it sometime takes a
couple of attempts to get the filter to "kick in").

Any ideas on what is happening here?

By the way, thanks for your help!


On Apr 17, 11:44 am, "jgeerdes [AJAX APIs \"Guru\"]"

jgeerdes [AJAX APIs "Guru"]

unread,
Apr 18, 2008, 6:32:03 AM4/18/08
to Google AJAX API
Yeah, the problem is that the initial search is being executed before
the restriction is being set. When you click off that link for a few
seconds (5 by default) and come back, the NewsBar will re-run the
search with the restriction in place. Try adding startupDelay : 1000
to your options var. This will instruct the bar to wait 1 second
before loading, which should be plenty of time to get your restriction
in place before the first search happens.

matrix-design

unread,
Apr 18, 2008, 8:40:15 PM4/18/08
to Google AJAX API
That's cracked it! Thanks for all your help.


On Apr 18, 8:32 pm, "jgeerdes [AJAX APIs \"Guru\"]"
<jgeer...@mchsi.com> wrote:
> Yeah, the problem is that the initial search is being executed before
> the restriction is being set. When you click off that link for a few
> seconds (5 by default) and come back, the NewsBar will re-run the
> search with the restriction in place. Try adding startupDelay : 1000
> to your options var. This will instruct the bar to wait 1 second
> before loading, which should be plenty of time to get your restriction
> in place before the first search happens.
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> jgeer...@mchsi.com
Reply all
Reply to author
Forward
0 new messages