Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twalling/foursquare-as3
Actionscript 3 API for Foursquare
https://github.com/twalling/foursquare-as3
Last synced: about 2 months ago
JSON representation
Actionscript 3 API for Foursquare
- Host: GitHub
- URL: https://github.com/twalling/foursquare-as3
- Owner: twalling
- Archived: true
- Created: 2011-03-15T02:13:21.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-04-06T02:16:48.000Z (almost 14 years ago)
- Last Synced: 2024-08-03T05:04:48.688Z (5 months ago)
- Language: ActionScript
- Homepage:
- Size: 87.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-actionscript-sorted - foursquare-as3 - Actionscript 3 API for Foursquare (API / Other API)
README
Introduction
============The foursquare API supports responses in either JSON or XML. The response format can be set on the service class and by default it's set to JSON. The service needs a base URL but its defaulted to http://api.foursquare.com/v1.
Create instance of service
==========================import com.timwalling.foursquare.FoursquareRequestFormat;
import com.timwalling.foursquare.FoursquareOperation;
import com.timwalling.foursquare.FoursquareService;
var service:FoursquareService = new FoursquareService();
service.timeout = 20; // optional timeout, default is no timeout
service.format = FoursquareRequestFormat.XML; // optionally if you want XML instead of JSONCreate operation for the API call
=================================var operation:FoursquareOperation = service.findVenues(LAT, LONG);
operation.addEventListener(Event.COMPLETE, handleComplete);
operation.addEventListener(ErrorEvent.ERROR, handleError);
operation.execute();
private function handleComplete(event:Event):void
{
trace(FoursquareOperation(event.target).data);
}
private function handleError(event:ErrorEvent):void
{
trace(event.text);
}Accessing response data
=======================
Since JSON or XML can be returned you can access the data in different ways. If you use the default which is JSON then another actionscript library is required to decode the JSON string. as3corelib has some JSON classes and the library can be found here: http://code.google.com/p/as3corelib/.JSON example:
import com.adobe.serialization.json.JSON;
var response:Object = JSON.decode(operation.data as String);If XML is preferred, no 3rd party libraries are needed and the data can be accessed directly as XML.
XML example:
var response:XML = operation.data as XML;