Welcome Developers!

in

Welcome!

in

Actionscript 2 REST API

Last post 07-08-2008 4:49 PM by Brock. 44 replies.
Page 1 of 3 (45 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 03-04-2008 4:25 PM

    Actionscript 2 REST API

    {Edit} 04-10-2008

    Made some important updates to this framework so I'm removing links to previous versions. If anyone is actually using the XML object I created I discovered that request cuing was not working at all so that's been fixed. Added a few services and removed groups & comment which are no longer in the documentation.

    Some of the parameters of service methods have changed. Sorry, no change log. Mostly it was around appdata calls. Still haven't found a solution for setting appdata, but I've come as close as I can without being able to implement PUT in the LoadVars object. The resulting request I generate works when pasted into the Firefox RESTTest plugin and is set to PUT.

    {Edit} 04-24-2008

    Setting appdata now working for token-based calls. 

    Download here:
    http://web.splashcast.net/share/MySpaceREST_v_1_03.zip

  • 03-04-2008 5:13 PM In reply to

    Re: Actionscript 2 REST API (Details)

    The core of this package is the class com.alpha0.rest.MySpaceXML, and, along with the supporting files, that's all you really need. If you scroll down to the "// MySpace Services" comment in the file you will see all the methods you can use to call REST services. In those methods, all the parameters including and after os_token are optional and will switch the calls from using OAuth authentication to using the token-based authentication.

    The file simpleTest.fla has a couple of simple examples of using MySpaceXML and MySpaceOAuthRequest & MySpaceTokenRequest separately.

    The file TestMySpaceREST.fla is intended more as documentation than as a usage sample. You can set this file up, via TestMySpaceREST.as, to test service calls and see the object tree MySpaceXML returns as a result. To test token-based results you'll either have to upload the SWF as your App Source, or pull those FlashVars out of the SWF you upload (from say the canvas page source) and plug those in to TestMySpaceREST.as. The calls will work from the Flash IDE, but will get blocked by myspace's crossdomain.xml if you try to run them outside of the IDE or the myspace domain.

    The class MySpaceXML subclasses XML so you can always pull the results out of it by using firstChild.toString(), but I've added functionality to parse the XML to an object tree making access to data a little easier. Rather than writing documentation for those data structures, I created TestMySpaceREST.fla as a tool to view those structures.

    Here are some differences between OAuth request and Token request. You can use a Token request to with VIEWER or OWNER to get those all important user IDs from Flash. The OAuth request require a user ID and are not limited to retrieving data of just the viewer or owner, but can retrieve data for any of your app users and in some cases their friends. Also, at this time, OAuth request support a greater range of REST services. 

    Here's a list of services that are currently implemented:

    getUser() - works on both

    getUserProfile() - works on both

    getFriends() - works on both

    isFriendOf() - works on both

    getAlbums() - works on both

    getAlbum() - works on both

    getPhotos() - works on both

    getPhoto() - works on both

    getInterest() - OAuth only

    getVideos() - works on both

    getVideo() - works on both

    getGroups() - Removed from docs

    getStatus() - OAuth only

    getMood() - OAuth only

    getComments() - Removed from docs

    getAppData() - works on both

    setAppData() - Token only

    NEW 

    getIndicators() - works on both 

    getFriendsAppData() - works on both

    getGlobalAppData()- works on both

    setGlobalAppData() - Token only

    I'll add new services as they come along and repost new versions here.

    I'm assuming that the token-based services currently not working will start working if MySpace adds functionality for them. 

    Also, let me know if you find any bugs and I'll try to fix and post those as well.

    ~Brock
    brock[at]splascastmedia.com

  • 03-04-2008 6:07 PM In reply to

    Re: Actionscript 2 REST API (Details)

     Great! thanks a lot:-)

  • 03-04-2008 7:14 PM In reply to

    • Sean
    • Top 500 Contributor
    • Joined on 02-06-2008
    • Posts 18

    Re: Actionscript 2 REST API (Details)

    Cool!

    Two questions: 

    • My Flash8 cannot open simpleTest.fla and TestMySpaceREST.fla - "Unexpected file format"?
    • How to send/request data from my own site with your class? (should thru MySpace proxy by MDP doc)

    Thanks 

  • 03-04-2008 11:31 PM In reply to

    Re: Actionscript 2 REST API (Details)

    Yeah, I'm currently working with Flash CS3, but this should be compatible with Flash 8 so I'll go ahead and save it out at that version and post new files up in the morning.

    You're going to have to load your file onto the myspace domain for these classes to work. The crossdomain.xml file on myspace api servers is locked down to exclude Flash developers from hosting their own files. 

  • 03-05-2008 8:47 AM In reply to

    Re: Actionscript 2 REST API (Details)

    OK, I replace the file with a version that has the FLAs saved out to Flash 8.
  • 03-05-2008 6:25 PM In reply to

    • Sean
    • Top 500 Contributor
    • Joined on 02-06-2008
    • Posts 18

    Re: Actionscript 2 REST API (Details)

    Yeah, now my flash8 can open the fla files, I cannot wait to play. Thanks Brock:-)

    Again about my 2nd question in my prevois reply, I know my app (swf) file should be hosted in MySpace, I wonder how to do when my app (hosted in ms) access my own site - http://www.MYOWNSITE.com/...:

    • Will the request (POST or GET) need go to MySpace proxy at first, and so does response from my site?
    • Btw the request need be wrapped with oAuth as well (to make ms proxy happy) ?
    • Moreover, I need a user_id (MySpace UserID) sent in each request with which my server-side script will save/query data on per user base. Can I send user_id obviously in request? Or, need my server extract it out thru oAuth (I presume opensocial token or something similiar be in each request)?

    Some questions might be out of scope of your this post, but they really frustrate me, it is very appreciated if you can help answer.

     Thanks

    Sean 

  • 03-06-2008 9:52 AM In reply to

    Re: Actionscript 2 REST API (Details)

    My framework has been created for direct comunication between the SWF file and MySpace REST API servers. As long as your file is on the myspace domain this will work fine. If you need to communicate with your own servers, then you may need to have a crossdomain.xml file setup in the root directory of your server to allow access. You could open it just the *.myspace.com domain or * all domains. 

    There's nothing in my framework for communication with your servers or proxing communication between MySpace and your servers. That said, you could construct the GET query and pass it to your severs to be proxied to MySpace. This would allow you to bypass having to create/use an API interface on your servers--it would just be simple URL forwarding.

    Example:
    var reqObj =  new MySpaceTokenRequest("VIEWER/friends",opensocial_token,opensocial_surface);
    xml.load("http://www.mydomain.com/forwarding.php?url="+escape(reqObj.getRequestURL()));

    You can get the user_id by using the opensocial_token with getUser() to return VIEWER & OWNER IDs (two separate calls).

    The framework is setup to use either OAuth or opensocial_token, never both in the same call.

    Hope that clarifies some of your questions.

    ~Brock 

  • 03-08-2008 7:33 AM In reply to

    • Sean
    • Top 500 Contributor
    • Joined on 02-06-2008
    • Posts 18

    Re: Actionscript 2 REST API (Details)

    Feedback: "Token request" works nice here; however "OAuth request" doesnot (I used "Token request" to get userid before filling in).

    P.S Do you know a flash implementation of "makeRequest(...)" function in js? 

    Thanks

    -Sean

  • 03-08-2008 1:31 PM In reply to

    Re: Actionscript 2 REST API (Details)

    Yes, OAuth request don't work with generic values like  VIEWER and OWNER, you need specific IDs to make OAuth request.

    makeRequest() for getting data from you own domain? That's the primary usage in opensocial right? Not too familiar with it. If you're looking to get data from your own domain then any of the standard practices should work. We use Flash Remoting. If there's some other functionality for makeRequest() I'd be interested in hearing about it.Don't know of any method for communicating with the opensocial framework through Flash.

    I did suggest at the SF devJam that MySpace could implement something similar to what Facebook has done and include a MySpace managed SWF, when we choose SWF as source, that had script access (ExternalInterface) and could proxy opensocial calls for our SWFs using LocalConnection. That would be the icing on the cake for Flash developers.

  • 03-08-2008 10:03 PM In reply to

    • Sean
    • Top 500 Contributor
    • Joined on 02-06-2008
    • Posts 18

    Re: Actionscript 2 REST API (Details)

    Brock:

    I did suggest at the SF devJam that MySpace could implement something similar to what Facebook has done and include a MySpace managed SWF, when we choose SWF as source, that had script access (ExternalInterface) and could proxy opensocial calls for our SWFs using LocalConnection. That would be the icing on the cake for Flash developers.

     

    And for MySpace itself as well, btw MySpace need not maintain another flash library?  It is interesting to know myspace'  responses on your suggestion :-), I know they are very busy this moment...

    Thanks for your great sample code again, it is vital for those rushing for 1st batch of myspace app lanuch and not familiar with oAuth issues, btw we win a lot of time more than just waiting for myspace' formal flash library...

    - Sean

  • 03-12-2008 5:00 PM In reply to

    Re: Actionscript 2 REST API

    Uploaded a new version of this framework:

    http://web.splashcast.net/share/MySpaceREST_v_1_01.zip

    Contains some fixes and two new methods:

    getAppData() - works for both OAuth and OS Token calls

    setAppData() - haven't gotten this working yet 

  • 04-09-2008 5:37 AM In reply to

    • Anu
    • Not Ranked
    • Joined on 04-09-2008
    • Posts 1

    Re: Actionscript 2 REST API

    Hello Sir ,

    I want to send flash object code to my myspace and facebook blog ,like it is in 

    http://www.yourminis.com/index_main.aspx

     

    Please Let me know If you have a solution for doing so .

  • 04-09-2008 10:40 AM In reply to

    Re: Actionscript 2 REST API

    Sorry, nothing currently in the MySpace REST API for creating blog post. And, there's no crossover between this API and Facebook's.

  • 04-10-2008 3:41 PM In reply to

    Re: Actionscript 2 REST API

Page 1 of 3 (45 items) 1 2 3 Next >