hi jeremy,

i am just trying a small example i got on the web on my android app

this is the HTML

<head>
    <title>Demo App</title>
    <script src="scripts/phonegap-1.0.0rc2.js"></script>
    <script src="scripts/jquery-1.6.4.min.js"></script>
    <script src="scripts/jquery.mobile.min.js"></script>
    <script src="scripts/dbfunc.js"></script>
    <link rel="stylesheet" href="css/jquery.mobile.min.css" />
    <script language="javascript" type="text/javascript"
src="scripts/gfeedfetcher.js"></script>
    <link rel="stylesheet" href="css/styles.css" />
</head>

<script type="text/javascript">
function getFeeds(){
    alert("get Feeds");
    var newsfeed=new gfeedfetcher("rssfeeds", "rssfeedsclass", "_new")
    newsfeed.addFeed("VANILLA", "
http://vanillajava.blogspot.com/feeds/posts/default?alt=rss";);
    newsfeed.addFeed("GOOGLE NEWS", "http://news.google.com/?output=rss";);
    newsfeed.addFeed("BLOGOOLA's Blog", "http://blogoola.com/blog/feed/";);
    newsfeed.displayoptions("label datetime snippet");
    newsfeed.setentrycontainer("p");
    newsfeed.filterfeed(15, "date");
    newsfeed.init();
}
</script>

i m calliing the get feed method on onclick event
which in turn calls the init method in getFeedFetcher.js

**********getFeedFetcher.js*********

// -------------------------------------------------------------------
// gAjax RSS Feeds Displayer- By Dynamic Drive, available at:
http://www.dynamicdrive.com
// Created: July 17th, 2007
// Updated June 14th, 10': Fixed issue in IE where labels would sometimes
be associated with the incorrect feed items
// -------------------------------------------------------------------

var gfeedfetcher_loading_image="indicator.gif" //Full URL to "loading"
image. No need to config after this line!!

google.load("feeds", "1") //Load Google Ajax Feed API (version 1)

function gfeedfetcher(divid, divClass, linktarget){
    this.linktarget=linktarget || "" //link target of RSS entries
    this.feedlabels=[] //array holding lables for each RSS feed
    this.feedurls=[]
    this.feeds=[] //array holding combined RSS feeds' entries from Feed API
(result.feed.entries)
    this.feedsfetched=0 //number of feeds fetched
    this.feedlimit=5
    this.showoptions="" //Optional components of RSS entry to show (none by
default)
    this.sortstring="date" //sort by "date" by default
    document.write('<div id="'+divid+'" class="'+divClass+'"></div>')
//output div to contain RSS entries
    this.feedcontainer=document.getElementById(divid)
    this.itemcontainer="<li>" //default element wrapping around each RSS
entry item
}

gfeedfetcher.prototype.addFeed=function(label, url){
    this.feedlabels[this.feedlabels.length]=label
    this.feedurls[this.feedurls.length]=url
}

gfeedfetcher.prototype.filterfeed=function(feedlimit, sortstr){
    this.feedlimit=feedlimit
    if (typeof sortstr!="undefined")
    this.sortstring=sortstr
}

gfeedfetcher.prototype.displayoptions=function(parts){
    this.showoptions=parts //set RSS entry options to show ("date,
datetime, time, snippet, label, description")
}

gfeedfetcher.prototype.setentrycontainer=function(containerstr){  //set
element that should wrap around each RSS entry item
this.itemcontainer="<"+containerstr.toLowerCase()+">"
}

gfeedfetcher.prototype.init=function(){
    alert("called");
    this.feedsfetched=0 //reset number of feeds fetched to 0 (in case
init() is called more than once)
    this.feeds=[] //reset feeds[] array to empty (in case init() is called
more than once)
    this.feedcontainer.innerHTML='<p><img
src="'+gfeedfetcher_loading_image+'" /> Retrieving RSS feed(s)</p>'
    var displayer=this
    for (var i=0; i<this.feedurls.length; i++){ //loop through the
specified RSS feeds' URLs
        var feedpointer=new google.feeds.Feed(this.feedurls[i]) //create
new instance of Google Ajax Feed API
        var items_to_show=(this.feedlimit<=this.feedurls.length)? 1 :
Math.floor(this.feedlimit/this.feedurls.length) //Calculate # of entries to
show for each RSS feed
        if (this.feedlimit%this.feedurls.length>0 &&
this.feedlimit>this.feedurls.length && i==this.feedurls.length-1) //If this
is the last RSS feed, and feedlimit/feedurls.length yields a remainder
            items_to_show+=(this.feedlimit%this.feedurls.length) //Add that
remainder to the number of entries to show for last RSS feed
        feedpointer.setNumEntries(items_to_show) //set number of items to
display
        feedpointer.load(function(label){
            return function(r){
                displayer._fetch_data_as_array(r, label)
            }
        }(this.feedlabels[i])) //call Feed.load() to retrieve and output
RSS feed.
    }
}


gfeedfetcher._formatdate=function(datestr, showoptions){
    var itemdate=new Date(datestr)
    var parseddate=(showoptions.indexOf("datetime")!=-1)?
itemdate.toLocaleString() : (showoptions.indexOf("date")!=-1)?
itemdate.toLocaleDateString() : (showoptions.indexOf("time")!=-1)?
itemdate.toLocaleTimeString() : ""
    return "<span class='datefield'>"+parseddate+"</span>"
}

gfeedfetcher._sortarray=function(arr, sortstr){
    var sortstr=(sortstr=="label")? "ddlabel" : sortstr //change "label"
string (if entered) to "ddlabel" instead, for internal use
    if (sortstr=="title" || sortstr=="ddlabel"){ //sort array by "title" or
"ddlabel" property of RSS feed entries[]
        arr.sort(function(a,b){
        var fielda=a[sortstr].toLowerCase()
        var fieldb=b[sortstr].toLowerCase()
        return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
        })
    }
    else{ //else, sort by "publishedDate" property (using error handling,
as "publishedDate" may not be a valid date str if an error has occured
while getting feed
        try{
            arr.sort(function(a,b){return new Date(b.publishedDate)-new
Date(a.publishedDate)})
        }
        catch(err){}
    }
}

gfeedfetcher.prototype._fetch_data_as_array=function(result, ddlabel){
    var thisfeed=(!result.error)? result.feed.entries : "" //get all feed
entries as a JSON array or "" if failed
    if (thisfeed==""){ //if error has occured fetching feed
        alert("Some blog posts could not be loaded: "+result.error.message)
    }
    for (var i=0; i<thisfeed.length; i++){ //For each entry within feed
        result.feed.entries[i].ddlabel=ddlabel //extend it with a "ddlabel"
property
    }
    this.feeds=this.feeds.concat(thisfeed) //add entry to array holding all
feed entries
    this._signaldownloadcomplete() //signal the retrieval of this feed as
complete (and move on to next one if defined)
}

gfeedfetcher.prototype._signaldownloadcomplete=function(){
    this.feedsfetched+=1
    if (this.feedsfetched==this.feedurls.length) //if all feeds fetched
        this._displayresult(this.feeds) //display results
}


gfeedfetcher.prototype._displayresult=function(feeds){
    var rssoutput=(this.itemcontainer=="<li>")? "<ul>\n" : ""
    gfeedfetcher._sortarray(feeds, this.sortstring)
    for (var i=0; i<feeds.length; i++){
        var itemtitle="<a rel=\"nofollow\" href=\"" + feeds[i].link + "\"
target=\"" + this.linktarget + "\" class=\"titlefield\">" + feeds[i].title
+ "</a>"
        var itemlabel=/label/i.test(this.showoptions)? '<span
class="labelfield">['+this.feeds[i].ddlabel+']</span>' : " "
        var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate,
this.showoptions)
        var itemdescription=/description/i.test(this.showoptions)? "<br
/>"+feeds[i].content : /snippet/i.test(this.showoptions)? "<br
/>"+feeds[i].contentSnippet  : ""
        rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " +
itemdate + "\n" + itemdescription + this.itemcontainer.replace("<", "</") +
"\n\n"
    }
    rssoutput+=(this.itemcontainer=="<li>")? "</ul>" : ""
    this.feedcontainer.innerHTML=rssoutput
}

i removed the following line
    <script type="text/javascript" language="javascript" src="
http://www.google.com/jsapi?key=ABQIAAAAFEyVt-pBJaTXzM__EKlCrBRyn6VRRdQGMLQqRPPw1fs6QDtVcBRGklOHzrf7hmoAX3qgxg4t5ImqRA
"></script>
 from the html
but still i am getting the same error

01-05 12:37:45.801: ERROR/Web Console(274): ReferenceError: Can't find
variable: google at file:///android_asset/www/scripts/gfeedfetcher.js:9

01-05 12:37:55.191: ERROR/Web Console(274): TypeError: Result of expression
'newsfeed.addFeed' [undefined] is not a function. at
file:///android_asset/www/home.html:19

Please help..



On Wed, Jan 4, 2012 at 10:53 PM, Jeremy Geerdes <[email protected]> wrote:

> When you load the loader, does the URL include key= at all? If it does,
> then the loader will try to check the key you've provided, and if it's not
> valid, it will fail to return. Otherwise, I would have no idea without
> being able to look at your page and see the code.
>
> Jeremy R. Geerdes
> Generally Cool Guy
> Des Moines, IA
>
> For more information or a project quote:
> [email protected]
>
> If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan
> Church!
>
> On Jan 4, 2012, at 11:12 AM, raghvendra garg wrote:
>
> hi jeremy,
> thanks for the reply
> but when i use the API without keys i get javascript error on line
> google.load("feeds", "1") that google is undefined for the page.
>
> what i thot that it may be due to api key.
>
> do u have any idea y i m getting this error if its not becoz of the key???
>
> On Wed, Jan 4, 2012 at 6:31 PM, Jeremy Geerdes <[email protected]>wrote:
>
>> First, you don't really need a key for the Feeds API. If you do want to
>> use one, though, what we usually recommend is set up a webpage somewhere
>> with basic information about your app. The TOS require you to provide a
>> valid HTTP_REFERER header, so use the url for your webpage in that header
>> and to generate your API key.
>>
>> Jg
>> On Jan 4, 2012 6:47 AM, "raghvendra garg" <[email protected]>
>> wrote:
>>
>>> Hi all,
>>>
>>> I am trying to use the gfeed api in my android application but I can’t
>>> understand how to generate api key for my application. Can anyone help me
>>> please..
>>>
>>> Thanks in advance.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Google AJAX APIs" group.
>>> To post to this group, send email to
>>> [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> To view this message on the web, visit
>>> http://groups.google.com/group/google-ajax-search-api?hl=en_US
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Google AJAX APIs" group.
>> To post to this group, send email to
>> [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> To view this message on the web, visit
>> http://groups.google.com/group/google-ajax-search-api?hl=en_US
>> For more options, visit this group at
>> http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
>>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google AJAX APIs" group.
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> To view this message on the web, visit
> http://groups.google.com/group/google-ajax-search-api?hl=en_US
> For more options, visit this group at
> http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Google AJAX APIs" group.
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> To view this message on the web, visit
> http://groups.google.com/group/google-ajax-search-api?hl=en_US
> For more options, visit this group at
> http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
http://groups.google.com/group/google-ajax-search-api?hl=en_US
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

Reply via email to