MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

makeRequest() implementation details

Last post 03-12-2008 10:26 AM by Karel. 23 replies.
Page 2 of 2 (24 items) < Previous 1 2
Sort Posts: Previous Next
  • 02-18-2008 3:14 PM In reply to

    • Mark
    • Top 50 Contributor
    • Joined on 02-05-2008
    • Posts 72

    Re: makeRequest() implementation details

    Is the opensocial.ContentRequestParameters.HEADERS param implemented yet?  I can't seem to get any test headers I set passed to my app.  I've tried the following just to see if I can get anything, and it doesn't seem to work.

    params[opensocial.ContentRequestParameters.HEADERS] = {'MY_TEST':  'hello'}; 

    Thanks,

    Mark 

  • 02-19-2008 11:12 AM In reply to

    • VK
    • Top 500 Contributor
    • Joined on 02-01-2008
    • Posts 11

    Re: makeRequest() implementation details

    has anyone attempted to use multiple makeRequest calls in a single app?

    when i tried it, only the last makeRequest call seemed to trigger the callback method. 

  • 02-19-2008 12:36 PM In reply to

    Re: makeRequest() implementation details

    It's possible, but it seems you're only allowed to have one makeRequest "active" at a time, so to do multiple ones, you'll have to wait for your first to return first. Since you can't judge when that will be, it's best to make the second call inside the callback of the first.

  • 02-19-2008 1:52 PM In reply to

    • VK
    • Top 500 Contributor
    • Joined on 02-01-2008
    • Posts 11

    Re: makeRequest() implementation details

    ahh, i see.

    Got multiple makeRequest calls to work with the piece of knowledge from Jeremy above =)

    Thanks, Jeremy. 

  • 02-20-2008 5:12 PM In reply to

    • Egg
    • Top 50 Contributor
    • Joined on 02-05-2008
    • Posts 73

    Re: makeRequest() implementation details

    Signal Loss:

    The JS portion of SIGNED has already rolled out, the associated proxy pieces should be rolling (if they haven't already) very shortly.

     In the meantime, you can always append opensocial_authtype=SIGNED to your makeRequest url.

    Cheers,

    Max 

    I'm not getting this at all... I have the following code:

    var osParams = {};
    osParams[opensocial.ContentRequestParameters.CONTENT_TYPE] = opensocial.ContentRequestParameters.ContentType.FEED;
    osParams[opensocial.ContentRequestParameters.METHOD] = opensocial.ContentRequestParameters.MethodType.POST;
    osParams[opensocial.ContentRequestParameters.POST_DATA] = "vara=more&varb=data";
    osParams[opensocial.ContentRequestParameters.AUTHORIZATION] = opensocial.ContentRequestParameters.AuthorizationType.SIGNED;
    opensocial.makeRequest('http://www.example.com', callback_func, osParams);

    To which my server receives appended via GET to the query string:

    oauth_consumer_key = "http://www.example.com/opensocial/"
    oauth_token = ""
    oauth_signature_method = "HMAC-SHA1"
    oauth_signature = ""
    oauth_timestamp = "3"
    oauth_nonce = "-101534"
    oauth_version = "1.0"

    Clearly this isn't right - am I missing the point somewhere? I was expecting a hash in oauth_signature that I could check to validate the request.

    Thanks for your help,
    Erik

  • 02-20-2008 9:43 PM In reply to

    Re: makeRequest() implementation details

    Nope, conceptually, you have it right. However, they recently updated the Common Questions sticky with this:

    Q: How do I validate that a makeRequest call actually came from the particular viewer and owner identified in the request?
    A: We're currently having some problems with this but hope to have it fixed very soon. When it's up, send opensocial.ContentRequestParameters.AuthenticationType.SIGNED into your makeRequest call.  Doing so will cause OAUTH to digitally sign the request and will allow you to verify the identity of the viewer and owner.

    Obviously, one of the problems is that it's not actually being signed.

  • 02-23-2008 8:16 AM In reply to

    • Karel
    • Not Ranked
    • Joined on 02-04-2008
    • Posts 8

    Re: makeRequest() implementation details

    Could someone please post a code snippet that successfully pulls from an external URL into the canvas? I've seen that a lot of people have this working, so perhaps this is just a temporary platform glitch? 
    This "sample code" called "working app 2" does not work from the canvas. The alert pops up with "http://www.msappspace.com" only, not the content of the external page.
    from http://developer.myspace.com/community/opensocial/create_app.aspx
    <script>
    function init()
    {
    var url = "http://www.w3.org";
    os_params = {};
    opensocial.makeRequest(url, makeRequest_Callback, os_params);
    function makeRequest_Callback(data){
    var responseText = data.responseText;
    alert(responseText);
    }
    }
    init();
    </script>
    So I look to this implementation details forum thread and I try to use myspaceseattlemax's code, from the first post of this thread, as
    <div id="output"></div>
    Point1
    <script>
    function init() {
    var url = "http://www.w3.org";
    os_params = {};
    os_params[opensocial.ContentRequestParameters.METHOD] = opensocial.ContentRequestParameters.MethodType.GET;
    opensocial.makeRequest(url, makeRequest_Callback, os_params);
    }
    function makeRequest_Callback(response, error) {
    var content = response.responseText;
    document.getElementById("output").innerHTML += "<br />" + content;
    document.getElementById("output").innerHTML += "<br />" + "Point2";
    }
    init();
    </script>

    This prints Point1 and Point2, but only prints Undefined as the content of the url.

    I'm seeing this as one error:

     /relay.proxy?opensocial_token=MIGnBgorBgEEAYI3WAOYoIGYMIGVBgorBgEEAYI3WAMBoIGGMIGDAgMCAAECAmYDAgIAwAQIMDaRULVx%2bKcEEHS8atNhlCahsWX7VTxD%2bSUEWPhBnsJgEW7tifAZDaPMRsnrLhUZu28aJuts%2f6yaOLbehr0sRF6T%2fZ% 
    Separately, the code tester on http://developer.myspace.com/community/opensocial/create_app.aspx always gives me the "enter application code" error in red.
  • 02-23-2008 8:59 AM In reply to

    • Karel
    • Not Ranked
    • Joined on 02-04-2008
    • Posts 8

    Re: makeRequest() implementation details

    http://developer.myspace.com/Community/forums/p/37/1765.aspx 

    In this thread I found that relay.proxy errors have been seen before, so now I'm even more suspecting that the code in my last post is fine, and waiting for a platform fix. 

  • 03-12-2008 10:26 AM In reply to

    • Karel
    • Not Ranked
    • Joined on 02-04-2008
    • Posts 8

    Re: makeRequest() implementation details

    This works now:

    <div id="target" style="padding:10px;">

    waiting....
    </div>

    <script>
        function init()    {
            var geturl = "http://www.w3.org";
            var target = document.getElementById('target');
           var os_params = {};
            try {
                os_params[opensocial.ContentRequestParameters.METHOD] = opensocial.ContentRequestParameters.MethodType.GET;
            opensocial.Container.get().makeRequest(geturl, makeRequest_Callback, os_params);
            }catch(er){
            target.style.backgroundColor = '#f00';
            target.style.color = '#fff';
            target.innerHTML = er.message;   
            }
        }
       function makeRequest_Callback(response, url, errored) {
         if (!errored) {                 
         target.innerHTML = "<br />" + response;
        } else {
          target.innerHTML = 'error: ' + errored ;
        }
    }
    init();
    </script>

Page 2 of 2 (24 items) < Previous 1 2