Requesting Webservices in Flex 3
- Posted by kajyr on January 13th, 2009
- 5 Comments »
Follows Webservices, simple introduction.
In Flex 3 requesting data is really simple, since you really have to load a well know url which prints out XML (or JSON or whatever).
I assume you have read the introduction, here we are with a url that prints out informations about Cher’s top fans:
http://ws.audioscrobbler.com/2.0/?method=artist.gettopfans&artist=cher&api_key=xxxxxxxxxxxx
What we have to do is load that url with a mx:HTTPService Object and parse the result as XML. Simple, it isn’t?
First: create the HTTPService object:
GeSHi Error: GeSHi could not find the language mxml (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)
and the handlers
GeSHi Error: GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)
GeSHi Error: GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)
And oplà, in the data field you will have the returned xml, ready to be shown in your preferred component!
Hey,
I am working on a project that combines the last.fm api with adobe flex. I have spent hours trying to search for a good tutorial on how to integrate the last.fm webservices api into flex and call the various last.fm functions. However I am getting a really annoying problem. You say that you have to create an object(which I have done).
The problem is that, I keep getting this really annoying error message. “The reference to entity “artist” must end with the ‘;’ delimiter”. I’ve spent quite sometime, trying to fix it, and can’t find any flaw. Can you please help me out with this issue?
Thanks,
January 31st, 2009 at 16:10
For some reason It didn’t post the code. Here it is once again; ///mx:HTTPService id=”fetchData” url=”http://ws.audioscrobbler.com/2.0/?method=artist.gettopfans&artist=cher&api_key={myAPIkey}”
resultFormat=”xml” result=”handler(event)” fault=”error(event)”///
January 31st, 2009 at 16:12
Mmh it is possible that you have used & amp; (the html entity for ampersand) instead to the simple ampersand to separate the get variables?
Try using just the ampersand, and let me know :-)
January 31st, 2009 at 20:01
Sorry for the late reply, I will try it out very soon and will let you know if it is working or not :). Thanks for your prompt reply, appreciate it!
February 3rd, 2009 at 19:49
Hey, I am still unable to get rid of the error. It’s actually driving me nuts, could you perhaps email me the sample last.fm code you wrote, which integrates the getTopfans() function in actionscript? Perhaps I’ll get a better understanding of what’s wrong.
February 6th, 2009 at 03:28