XML-RPC
XML-RPC is the second request format supported by Flickr. XML-RPC uses HTTP as the transport and XML for encoding. In XML-RPC, the method parameters are wrapped in a XML document and POST-ed to the XML-RPC endpoint, in this case http://api.flickr.com/services/xmlrpc/.
A XML-RPC request will have this format:
<methodCall>
<methodName>flickr.test.echo</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>api_key</name>
<value><string>..your API key..</string></value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>
If the method takes more than one parameter, you will have to repeat the <member> structure for each parameter; you can find detailed instructions regarding the packaging of complex datatypes at www.xmlrpc.com.
Here is how to implement this call in Actionscript:
var request:XML;
var response:XML;
request=new XML();
response = new XML();
response.onLoad=function(success:Boolean){
trace(success);
trace(this.toString());
}
request.xmlDecl = '<?xml version="1.0"?>';
request.parseXML("<methodCall><methodName>flickr.test.echo</methodName><params>
<param><value><struct><member><name>api_key</name><value>..your API
key..</value></member></struct></value></param></params></methodCall>");
request.sendAndLoad("http://api.flickr.com/services/xmlrpc/", response);
Since this is a HTTP POST operation, I have to use the sendAndLoad method of the XML object.
Developer Matt Shaw is behind an open source project that provides a XML-RPC library for Actionscript; an introduction can be found at http://xmlrpcflash.mattism.com/, or you can download the library (more details can be found here). Using this library, the call to the echo function shown above would look like this:
import com.mattism.http.xmlrpc.Connection;
import com.mattism.http.xmlrpc.ConnectionImpl;
onLoadListing = function( response:Array ){
trace("Found the following objects:");
var i:Number;
for (i=0; i<response.length; i++){
trace(i+". "+url+response[i]);
}
};
var url:String = "http://api.flickr.com/services/xmlrpc/";
var c:Connection = new ConnectionImpl();
c.setUrl(url);
c.onLoad = onLoadListing;
c.addParam( { api_key:'...your API key...' }, "struct");
c.call("flickr.test.echo");
Contents contributed and discussions participated by marcell mars
http://transmote.com/flosc - 0 views
Put a Flex UI On Your Application - 0 views
Adobe Flash Served by Python - 0 views
-
from SimpleXMLRPCServer import SimpleXMLRPCServer,SimpleXMLRPCRequestHandler class ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): def do_GET(self): #only allow a request for the crossdomain file #this can be changed to support GETs of any file if needed if self.path != '/crossdomain.xml': self.send_response(403) self.log_request(403) return #open the crossdomain file and read its contents f = file('crossdomain.xml', 'r') msg = f.read() f.close() #write the data to the socket along with valid HTTP headers res = 'HTTP/1.0 200 OK\r\nDate: %s\r\n\r\n%s' % \ (self.date_time_string(),msg) self.wfile.write(res) self.log_request(200) class EchoClass: def echo(self, data): return data #create an instance of the class s = EchoClass() #create the server on localhost server = SimpleXMLRPCServer(('', 8000), ExtendedXMLRPCRequestHandler) #register the instance as a web service server.register_instance(s) #start accepting requests server.serve_forever()
« First
‹ Previous
41 - 45 of 45
Showing 20▼ items per page