Link to home
Create AccountLog in
Avatar of jrwalker2
jrwalker2

asked on

Flex 3 - Help with my Flickr Web Service calls

I am writing a program based on Adobe's Flex demo tutorial to call the Flickr API (http://labs.adobe.com/technologies/flexbuilder2/tutorials/). However, I am not able to get anything to return back from Flickr when I click the Find button. Am I doing something wrong? Thanks
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:HTTPService id="service" url="http://api.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=f09abdbe2fada94609244a5de3f4b8de&amp;per_page=9&amp;tags={input.text}" />
	<mx:states>
		<mx:State name="results">
			<mx:SetProperty target="{panel1}" name="width" value="70%"/>
			<mx:SetProperty target="{panel1}" name="height" value="70%"/>
			<mx:SetProperty target="{panel1}" name="x" value="110"/>
			<mx:SetProperty target="{panel1}" name="y" value="41"/>
			<mx:AddChild relativeTo="{panel1}" position="lastChild">
				<mx:TileList dataProvider="{service.lastResult.rsp.photos.photo}" bottom="38" right="21" left="23" top="72" itemRenderer=""></mx:TileList>
			</mx:AddChild>
		</mx:State>
	</mx:states>
	<mx:Panel x="159" y="37" width="391" height="129" layout="absolute" title="Photos" id="panel1" resizeEffect="Resize">
		<mx:Label x="23" y="32" text="Tags"/>
		<mx:TextInput x="88" y="30" id="input"/>
		<mx:Button x="274" y="30" label="Find" click="currentState='results'; service.send()"/>
	</mx:Panel>
	
</mx:Application>

Open in new window

Avatar of julianopolito
julianopolito
Flag of Brazil image

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="service.send()">
You should call send() to trigger the service call.
I'm sorry, Just saw you have that on the button. I'll take a further look into it .
Avatar of jrwalker2
jrwalker2

ASKER

Thanks julianopolito. I'd really appreciate your help.
Looks like the API key you are using is invalid
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
	<![CDATA[
		import mx.rpc.events.ResultEvent;
		import mx.controls.Alert;
		private function ok( e:ResultEvent):void
		{
			if( e.result.rsp.stat == "fail")
				Alert.show( e.result.rsp.err.msg);			 
		}
	]]>
</mx:Script>
<mx:HTTPService id="service" url="http://api.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=f09abdbe2fada94609244a5de3f4b8de&amp;per_page=9&amp;tags={input.text}" result="ok( event)"/>
	<mx:states>
		<mx:State name="results">
			<mx:SetProperty target="{panel1}" name="width" value="70%"/>
			<mx:SetProperty target="{panel1}" name="height" value="70%"/>
			<mx:SetProperty target="{panel1}" name="x" value="110"/>
			<mx:SetProperty target="{panel1}" name="y" value="41"/>
			<mx:AddChild relativeTo="{panel1}" position="lastChild">
				<mx:TileList dataProvider="{service.lastResult.rsp.photos.photo}" bottom="38" right="21" left="23" top="72"></mx:TileList>
			</mx:AddChild>
		</mx:State>
	</mx:states>
	<mx:Panel x="159" y="37" width="391" height="129" layout="absolute" title="Photos" id="panel1" resizeEffect="Resize">
		<mx:Label x="23" y="32" text="Tags"/>
		<mx:TextInput x="88" y="30" id="input"/>
		<mx:Button x="274" y="30" label="Find" click="currentState='results'; service.send()"/>
	</mx:Panel>	
</mx:Application>

Open in new window

Hi hobbit72,

When I use the code that you provided, I get the following error (when I try to search):

"Invalid API Key (Key not found)"

Note that the code would not compile until I added the following to my Flex Compiler arguments (Project preferences):

-use-network=true

All additional suggestions are greatly appreciated. Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Gary Benade
Gary Benade
Flag of South Africa image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Did you get this to work?
This worked perfectly. Thanks hobbit72!!!!!!!!