Can you post a copy of the XML that you are actually receiving from
the service?
if you put
trace(XML(evt.result).toXMLString());
in your
httpService_result function, you should get a look at the XML that is
being sent to your application from the web service.
At a glance here, my guess is that the "@" may not be needed, or that
you are just asking for the wrong variable. You use the @ symbol to
specify XML attributes, if you omit the @ symbol, you are specifying
XML elements. So the answer depends on XML that you are receiving. If
I had to guess, I would guess you probably need
data.url
or
[EMAIL PROTECTED]
Rob
function, you should get a dump of the XML that
On Nov 27, 2008, at 7:05 PM, spinglittery wrote:
I am a relative newbie in the Flex and development world, trying to
extend my design
skills. So please forgive any foolish errors. Presently I am
attempting to communicate with
the photoshelter api via httpservice, and need help. I can
successfully log-in and get
authorisation - but cannot work out how to actually access albums
and galleries via their
api xml syntax. (...although it looks as though it should be
straightforward...) I have tried
adapting code I found on flexexamples - dynamically-loading-xml-
files-using-the-
httpservice-tag:
<mx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
private var alert:Alert;
public function
setRemoteCredentials
(remoteUsername:String="xxxx",remotePassword:String="xxxxx",
charset:String = null):void
{
httpService.url="https://www.photoshelter.com/bsapi/1.1/auth";
httpService.send(setRemoteCredentials);
}
private function loadGallery(src:String):void {
httpService.url = "https://www.photoshelter.com/bsapi/1.1/alb-qry";
httpService.send();
}
private function httpService_fault(evt:FaultEvent):void {
var title:String = evt.type + " (" + evt.fault.faultCode + ")";
var text:String = evt.fault.faultString;
alert = Alert.show(text, title);
xmlListColl.removeAll();
}
private function httpService_result(evt:ResultEvent):void {
var xmlList:XMLList = XML(evt.result).alb;
xmlListColl = new XMLListCollection(xmlList);
trace("Done!");
}
]]>
</mx:Script>
<mx:XMLListCollection id="xmlListColl" />
<mx:HTTPService id="httpService"
resultFormat="e4x"
showBusyCursor="true"
fault="httpService_fault(event);"
result="httpService_result(event)" />
<mx:ApplicationControlBar dock="true">
<mx:Button label="Data" click="setRemoteCredentials()"/>
<mx:Button label="Travel"
click="loadGallery('Travel');" />
<mx:Button label="Landscapes"
click="loadGallery('Landscapes UK');" />
<mx:Button label="gallery 404"
click="loadGallery('gallery404.xml');" />
</mx:ApplicationControlBar>
<mx:TileList id="tileList"
dataProvider="{xmlListColl}"
itemRenderer="TileListItemRenderer"
columnCount="3"
columnWidth="150"
rowCount="2"
rowHeight="100" />
</mx:Application>
------------------
//TileListItemRenderer//
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Image source="[EMAIL PROTECTED]"
horizontalCenter="0"
verticalCenter="0" />
</mx:Canvas>
I am unsure what I should put as the source - and have tried
[EMAIL PROTECTED] as well as [EMAIL PROTECTED] But I am not
sure that I am querying the api correctly... Whatever
I am doing wrong, it also prevents the gallery 404 error message
appearing anymore...
Any help would be greatly appreciated.