0

Flex examples for Y Social

I am a complete newbie.
There are a few Flex examples. http://developer.yahoo.com/flash/yos/examp...ml#flex_section
I am not sure how to run those. Could you please help?
Thank you.
By the way, looks like small view does not allow <yml:swf>?

by
21 Replies
  • Say I enter an url for canvas like: http://<my domain>/yahootestapp.html.
    yahootestapp.html contains a single line:
    <yml:swf src="YAPProfile.swf" width="540" height="480" />

    When I preview canvas view, it shows the following line:

    "Oops. The app couldn't load for some reason. If you reload the page it might work. If you see this error more than once, please let us know. "

    Any comments are appreciated.
    0
  • QUOTE (sipcommunication @ Oct 28 2008, 10:50 AM) <{POST_SNAPBACK}>
    By the way, looks like small view does not allow <yml:swf>?


    Yes, swf is not available in the small view (http://developer.yahoo.com/yap/yml/swf.html) so you will have to test it by pointing the application URL to a server that hosts the application containing the swf.
    0
  • I think you need to use the full path to your swf file in the <yml:swf> tag. Try using it with the full path http://<my domain>/YAPProfile.swf and let us know if that works.
    0
  • QUOTE (sipcommunication @ Oct 28 2008, 11:39 AM) <{POST_SNAPBACK}>
    Say I enter an url for canvas like: http://<my domain>/yahootestapp.html.
    yahootestapp.html contains a single line:
    <yml:swf src="YAPProfile.swf" width="540" height="480" />

    When I preview canvas view, it shows the following line:

    "Oops. The app couldn't load for some reason. If you reload the page it might work. If you see this error more than once, please let us know. "

    Any comments are appreciated.


    When the request goes to your server, POST is used rather than GET. Make sure your server allow POST on .html extention.
    0
  • QUOTE (Brett @ Oct 28 2008, 12:50 PM) <{POST_SNAPBACK}>
    I think you need to use the full path to your swf file in the <yml:swf> tag. Try using it with the full path http://<my domain>/YAPProfile.swf and let us know if that works.


    Thank you very much, I think that does the trick. :)
    0
  • QUOTE (c J @ Oct 28 2008, 01:15 PM) <{POST_SNAPBACK}>
    When the request goes to your server, POST is used rather than GET. Make sure your server allow POST on .html extention.

    Thank you. That's valuable to know.
    I wonder if there are documentation that shows lists of parameters that are sent with post.
    0
  • Thanks for everyone who replied so far. It was very helpful. :)yap_appid
    0
  • QUOTE (sipcommunication @ Oct 28 2008, 02:48 PM) <{POST_SNAPBACK}>
    Thanks for everyone who replied so far. It was very helpful. :) YahooSession.YAP_APPID = flashvars.yap_appid;
    0
  • QUOTE (sipcommunication @ Oct 28 2008, 02:50 PM) <{POST_SNAPBACK}>
    For more detailed info, the example uses the following code to get the attributes from flashvars.

    var flashvars:Object = Application.application.parameters;

    var ck:String = flashvars.yap_consumer_key; // consumer key
    var cks:String = CONSUMER_SECRET; // consumer secret
    var atk:String = flashvars.yap_viewer_access_token; // access token
    var ats:String = flashvars.yap_viewer_access_token_secret; // access token secret

    YahooSession.YAP_OWNER = flashvars.yap_owner_guid;
    YahooSession.YAP_VIEWER = flashvars.yap_viewer_guid;
    YahooSession.YAP_APPID = flashvars.yap_appid;


    Hi,

    For the consumer key, you can either define it in ActionScript or pass it through flashvars. It is also provided in the POST to your page.

    The viewer access token & secret is also in the POST, along with the viewer and owner GUIDs.

    If you want to get them into Flash the quick & dirty way, just turn the POST array into a query string and use that as the flashvars in yml:swf.

    php example:

    CODE
    <?php
    $flashvars = http_build_query($_POST);

    $yml = <<<YML
    <yml:swf src="${swf}.swf" width="550" height="400" flashvars="$flashvars"/>
    YML;

    echo $yml;
    ?>


    There are better and more secure ways to do this (you end up printing your secrets to the page), but that should get you started.

    Also, yml:swf will provide the owner & viewer guids in the flashvars by default. those values are 'yap_owner' and 'yap_user'. However the code example used the POST values to be more generic, since the Flash SDK is not limited just to YAP.

    Also see:
    http://developer.yahoo.com/yap/guide/yap-params.html

    Thanks,
    Zach
    0
  • Thank you, Zach. That's exactly what I need. :)Zach
    0
  • QUOTE (sipcommunication @ Oct 28 2008, 10:26 PM) <{POST_SNAPBACK}>
    Thank you, Zach. That's exactly what I need. :)By the way, Facebook platform also puts the session_key and other information in <fb:swf> to allow developers to authenticate using just flashvars provided by <fb:swf>.
    0
  • QUOTE (sipcommunication @ Oct 28 2008, 10:31 PM) <{POST_SNAPBACK}>
    By the way, Facebook platform also puts the session_key and other information in <fb:swf> to allow developers to authenticate using just flashvars provided by <fb:swf>.


    We're working on it. Hopefully we'll have an updated Flash SDK soon that will support the current OAuth flow *and* a session token for YAP.
    0
  • QUOTE (Zach Graves @ Oct 29 2008, 12:29 AM) <{POST_SNAPBACK}>
    We're working on it. Hopefully we'll have an updated Flash SDK soon that will support the current OAuth flow *and* a session token for YAP.


    Sounds good. I don't know anything about how the authentication works yet, but that sounds good that Yap will be working on adding the parameters to flashvars in <yml:swf> to allow more client-side mash-up development. :)Thank you for the prompt reply.
    0
  • Thank you for the answer so far, I am making progress.

    Now I receive this error message. (I am attempting the get profile example (YAPProfile.mxml))

    Error loading data from http://social.yahooapis.com/v1/user/<user guid>/profile


    I printed out the parameters from POSt and print out the parameters received from flashvars. They are the same value.
    If you would like to see the app, I can send you the link. It prints out the parameters inside flash and on the page for comparison purpose.

    Another related question is whether there is a way to find out the error code of the response.

    Thank you.
    0
  • QUOTE (sipcommunication @ Oct 30 2008, 02:18 AM) <{POST_SNAPBACK}>
    Thank you for the answer so far, I am making progress.

    Now I receive this error message. (I am attempting the get profile example (YAPProfile.mxml))

    Error loading data from http://social.yahooapis.com/v1/user/<user guid>/profile


    I printed out the parameters from POSt and print out the parameters received from flashvars. They are the same value.
    If you would like to see the app, I can send you the link. It prints out the parameters inside flash and on the page for comparison purpose.

    Another related question is whether there is a way to find out the error code of the response.

    Thank you.


    Unfortunately Flash Player does not return response headers or codes due to plug-in limitations. However in most cases you can see the request through firebug and see the response. Look at the status code and the WWW-Authenticate header value, it should provide some sort of error message on why the request failed. Also check that your consumer secret is defined somewhere. Feel free to post the code too.
    0
  • QUOTE (basictheory @ Oct 31 2008, 11:04 AM) <{POST_SNAPBACK}>
    Unfortunately Flash Player does not return response headers or codes due to plug-in limitations. However in most cases you can see the request through firebug and see the response. Look at the status code and the WWW-Authenticate header value, it should provide some sort of error message on why the request failed. Also check that your consumer secret is defined somewhere. Feel free to post the code too.


    Thank you for the response. Looks like the error is

    401 authorization required social.yahooapis.com
    signature_invalid

    when calling
    http://social.yahooapis.com/v1/user/DRF76F...QeX1MI6lky2M%2D

    CODE
    Response Headers
    Date Sun, 02 Nov 2008 09:45:28 GMT
    WWW-Authenticate OAuth oauth_problem="signature_invalid", realm="yahooapis.com"
    Vary Accept-Encoding
    Content-Type application/json
    Age 0
    Transfer-Encoding chunked
    Connection keep-alive
    Server YTS/1.17.9

    Request Headers
    Host social.yahooapis.com
    User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language en-us,en;q=0.5
    Accept-Encoding gzip,deflate
    Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive 300
    Connection keep-alive



    If you want to see the app, you may go to:
    http://apps.yahoo.com/-T54MJg36

    The Flex swf is YAPProfile.mxml copied straight from http://developer.yahoo.com/flash/yos/examp...rofile/srcview/. The only change is replacing consumer_secret.

    Thank you.
    0
  • i'm having a similar problem using this app.

    fine with straight yml and php examples, but the flash app, in full view does nothing.

    doesn't even seem to connect or try to get profile information (no pass or fail event notifications).

    anyone has a 3rd party hosted flex app working?
    0
  • i'm seeing this in the firebug console, fwiw.

    starting loadModule
    done loadModule
    ob.toString is not a function
    [Break on this error] (function(){YAHOO.namespace("yap.YML.tag...],Y)}Y=true}}();R.run();return R}()})();
    malky-BG...kGJ6Q-.js (line 1)
    Permission denied to get property Location.toString
    [Break on this error] (function(){YAHOO.namespace("yap.YML.tag...],Y)}Y=true}}();R.run();return R}()})();
    malky-BG...kGJ6Q-.js (line 1)
    _yapFlashProxy-e2B6eq7e is already open
    Permission denied to call method Location.toString
    [Break on this error] undefined
    _yapFlashProxy-e2B6eq7e is already open


    QUOTE (enoch @ Nov 2 2008, 06:39 PM) <{POST_SNAPBACK}>
    i'm having a similar problem using this app.

    fine with straight yml and php examples, but the flash app, in full view does nothing.

    doesn't even seem to connect or try to get profile information (no pass or fail event notifications).

    anyone has a 3rd party hosted flex app working?
    0
  • QUOTE (sipcommunication @ Nov 2 2008, 02:07 AM) <{POST_SNAPBACK}>
    Thank you for the response. Looks like the error is

    401 authorization required social.yahooapis.com
    signature_invalid

    when calling
    http://social.yahooapis.com/v1/user/DRF76F...QeX1MI6lky2M%2D

    CODE
    Response Headers
    Date Sun, 02 Nov 2008 09:45:28 GMT
    WWW-Authenticate OAuth oauth_problem="signature_invalid", realm="yahooapis.com"
    Vary Accept-Encoding
    Content-Type application/json
    Age 0
    Transfer-Encoding chunked
    Connection keep-alive
    Server YTS/1.17.9

    Request Headers
    Host social.yahooapis.com
    User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language en-us,en;q=0.5
    Accept-Encoding gzip,deflate
    Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive 300
    Connection keep-alive



    If you want to see the app, you may go to:
    http://apps.yahoo.com/-T54MJg36

    The Flex swf is YAPProfile.mxml copied straight from http://developer.yahoo.com/flash/yos/examp...rofile/srcview/. The only change is replacing consumer_secret.

    Thank you.


    Could you double check that the access token and access token secret is being passed into the app via flashvars? Note that YAP doesn't provide these variables, but you need to pass them in manually. That error suggests that the AS3 code signed the request successfully given the info it has, but errored out because something was missing/invalid.

    Something like this:

    CODE
    var ck:String = "myConsumerKey";
    var cks:String = "myConsumerSecret";
    var atk:String = "myAccessToken";
    var ats:String = "myAccessTokenSecret";

    YahooSession.YAP_VIEWER = "ABCDEFGHIJKLMOPQRSTUVWXYZ";
    YahooSession.YAP_APPID = "FOOAPPID";

    _session = new YahooSession(ck, cks, atk, ats);
    _user = _session.getSessionedUser();
    0
  • QUOTE (basictheory @ Nov 3 2008, 02:54 PM) <{POST_SNAPBACK}>
    Could you double check that the access token and access token secret is being passed into the app via flashvars? Note that YAP doesn't provide these variables, but you need to pass them in manually. That error suggests that the AS3 code signed the request successfully given the info it has, but errored out because something was missing/invalid.

    Something like this:

    CODE
    var ck:String = "myConsumerKey";
    var cks:String = "myConsumerSecret";
    var atk:String = "myAccessToken";
    var ats:String = "myAccessTokenSecret";

    YahooSession.YAP_VIEWER = "ABCDEFGHIJKLMOPQRSTUVWXYZ";
    YahooSession.YAP_APPID = "FOOAPPID";

    _session = new YahooSession(ck, cks, atk, ats);
    _user = _session.getSessionedUser();



    Thank you for the reply, BasicTheory.
    In order to check that atk and ats are passed into swf, I had uploaded a slightly different version of swf that prints out the cks, atk, and ats onto Alert.
    It is here: http://apps.yahoo.com/-T54MJg36
    The FullView page also prints out the access token , access token secret parameters. I compared them a few days ago, and they seems to be the same, assuming that I had done escape/unescape correctly. The page itself is created with Python. If there is anything that I should watch out when doing the escaping on Python, please don't hesitate to speak out, no matter how obvious you might think it is.
    You may also take a look at the page and check whether atk and ats are correct: http://apps.yahoo.com/-T54MJg36


    Here is the code that I used to print out the data:
    CODE
    				var flashvars:Object = Application.application.parameters;

    var ck:String = flashvars.yap_consumer_key; // consumer key
    var cks:String = CONSUMER_SECRET; // consumer secret
    var atk:String = flashvars.yap_viewer_access_token; // access token
    var ats:String = flashvars.yap_viewer_access_token_secret; // access token secret

    YahooSession.YAP_OWNER = flashvars.yap_owner_guid;
    YahooSession.YAP_VIEWER = flashvars.yap_viewer_guid;
    YahooSession.YAP_APPID = flashvars.yap_appid;

    Alert.show("handleInitialize(). ck="+ck+"\n cks="+cks+"\n atk="+atk+"\n ats="+ats+"\n yap_owner="+YahooSession.YAP_OWNER+"\n yap_viewer="+YahooSession.YAP_VIEWER+"\n app_id="+YahooSession.YAP_APPID);



    Here is the full code:
    CODE
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundGradientColors="[#FEFEFE, #E8E8E8]"
    initialize="handleInitialize(event);"
    layout="absolute"
    width="780" backgroundGradientAlphas="[1.0, 1.0]" viewSourceURL="srcview/index.html">

    <mx:Script>
    <![CDATA[
    import flash.net.navigateToURL;
    import mx.controls.Alert;
    import com.yahoo.social.data.Profile;
    import com.yahoo.social.events.YahooResultEvent;
    import com.yahoo.social.YahooUser;
    import com.yahoo.social.YahooSession;
    import mx.events.FlexEvent;

    private var _session:YahooSession;

    [Bindable]
    private var _viewerProfile:Profile;

    [Bindable]
    private var _nickname:String = "";

    [Bindable]
    private var _location:String = "";

    private static const CONSUMER_SECRET:String = "dj0yJmk9ZmVVTjlVRGowYmNiJmQ9WVdrOVZEVTBUVXBuTXpZbWNHbzlNak15TWprek16RTImcz1j
    b25zdW1lcnNlY3JldCZ4PWE3";

    private function handleInitialize(event:FlexEvent):void
    {
    var flashvars:Object = Application.application.parameters;

    var ck:String = flashvars.yap_consumer_key; // consumer key
    var cks:String = CONSUMER_SECRET; // consumer secret
    var atk:String = flashvars.yap_viewer_access_token; // access token
    var ats:String = flashvars.yap_viewer_access_token_secret; // access token secret

    YahooSession.YAP_OWNER = flashvars.yap_owner_guid;
    YahooSession.YAP_VIEWER = flashvars.yap_viewer_guid;
    YahooSession.YAP_APPID = flashvars.yap_appid;

    Alert.show("handleInitialize(). ck="+ck+"\n cks="+cks+"\n atk="+atk+"\n ats="+ats+"\n yap_owner="+YahooSession.YAP_OWNER+"\n yap_viewer="+YahooSession.YAP_VIEWER+"\n app_id="+YahooSession.YAP_APPID);

    _session = new YahooSession(ck, cks, atk, ats);

    var user:YahooUser = _session.getSessionedUser();
    user.profile.addEventListener(YahooResultEvent.GET_PROFILE_SUCCESS, handleUserGetProfile);
    user.profile.addEventListener(YahooResultEvent.GET_PROFILE_FAILURE, handleUserGetProfileFail);
    user.profile.getProfile();
    }

    private function handleUserGetProfileFail(event:YahooResultEvent):void
    {
    Alert.show("Error loading data from "+event.data.url, "Error");
    }

    private function handleUserGetProfile(event:YahooResultEvent):void
    {
    Alert.show("handleUserGetProfile()");
    _viewerProfile = event.data as Profile;
    _nickname = _viewerProfile.nickname;
    _location = _viewerProfile.location;
    txtNickname.text = _viewerProfile.nickname;
    txtLocation.text = _viewerProfile.location;
    }
    ]]>
    </mx:Script>

    <mx:Image width="192" height="192" source="{_viewerProfile.image.imageUrl}" horizontalCenter="0" top="10"/>
    <mx:Text id="txtNickname" text="" fontFamily="Arial" fontSize="14" color="#333333" horizontalCenter="0" top="210"/>
    <mx:Text id="txtLocation" text="" fontFamily="Arial" fontSize="14" color="#333333" horizontalCenter="0" top="230" fontStyle="italic"/>
    <mx:LinkButton y="260" click="flash.net.navigateToURL(new URLRequest(_viewerProfile.profileUrl),'_blank');" label="View my Profile" horizontalCenter="0" color="#860078"/>
    </mx:Application>
    0
  • Hi, is there any new finding on this front?

    After comparing the token received by the page through POST with the values received by swf through flashvars. They seem to be the same. What should be the next thing for us to check?

    Appreciate to get any comment.
    0
  • Recent Posts

    in YAP