Table of Contents
PyAMF AMF Client
PyAMF isn't just about the flash client talking to a Python backend, oh no. We have put together a client module which allows you to make AMF calls to an HTTP Gateway, whether that be PyAMF or other AMF implementations. If you come from a Flash background, this API will feel very natural to you.
Examples
This examples below are working, so feel free to try this out right now.
Basic Example
from pyamf.remoting.client import RemotingService client = RemotingService('http://demo.pyamf.org/gateway/recordset') service = client.getService('service') print service.getLanguages()
Authentication
Use setCredentials(username, password) to authenticate with an AMF client:
from pyamf.remoting.client import RemotingService client = RemotingService('https://demo.pyamf.org/gateway/authentication') client.setCredentials('jane', 'doe') service = client.getService('calc') print service.sum(85, 115) # should print 200.0 client.setCredentials('abc', 'def') print service.sum(85, 115).description # should print Authentication Failed
Logging
from pyamf.remoting.client import RemotingService import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s') client = RemotingService('http://demo.pyamf.org/gateway/recordset') service = client.getService('service') print service.getLanguages()
HTTP Headers
You can modify the headers of the HTTP request using this convenient api:
from pyamf.remoting.client import RemotingService gw = RemotingService('http://demo.pyamf.org/gateway/recordset') gw.addHTTPHeader('Set-Cookie', 'sessionid=QT3cUmACNeKQo5oPeM0') gw.removeHTTPHeader('Set-Cookie')
More
Check the api docs for more information. The source for the RecordSet example is also available.
