Welcome Developers!

in

Welcome!

in

Pass variables to RequestRender

Last post 06-02-2010 3:04 PM by Joel. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-19-2010 6:17 AM

    • Peter
    • Top 500 Contributor
    • Joined on 09-13-2009
    • Posts 16

    Pass variables to RequestRender

    I am trying to fetch a page which renders different content depending on where it is shown (the owner). In your examples, you say this is possible: http://wiki.developer.myspace.com/index.php?title=External_Rendered_Content_with_OSML

    But when I try to do this, the UserID is not outputted. It loads this page:

    http://example.com/myspace.php?id=${owner.id}

    instead of:

    http://example.com/myspace.php?id=myspace.com.person.53XXX22

    if I use  ${owner.id} anywhere else on the page, it outputs fine. It just won't work within quote.

    The same happens for osx:Get and osx:RequestRender.

    Would greatly appreciate any help on how to fetch a dynamic page.

    Here is my code:

    <?xml version="1.0" encoding="utf-8"?>
    <Module xmlns:os="http://ns.opensocial.org/2008/markup" xmlns:myspace="http://ns.opensocial.org/2008/x" xmlns:my="http://ns.opensocial.org/2008/z">
      <ModulePrefs title="Test" description="Testing">
        <Require feature="opensocial-1.0"/>
        <Require feature="opensocial-templates"/>
      </ModulePrefs>
      <Content type="html" view="canvas">
        <script type="text/os-data">
          <os:OwnerRequest key="owner" />
        </script>
        <script type="text/os-template">
            <style>
            #loader { padding:160px 0 0 160px; color: #ccc; }
            #target { overflow:auto; }
            </style>    
            <div id="target">
                <div id="loader">Loading gigs...</div>
            </div>
            <osx:RenderRequest target="target" src="http://example.com/myspace.php?id=${owner.id}"  />
        </script>
      </Content>
    </Module>

  • 05-20-2010 4:25 PM In reply to

    Re: Pass variables to RequestRender

     Hi,

    I have escalated this issue to our dev team.

     

    thanks,

    Joel

  • 05-20-2010 8:46 PM In reply to

    • Peter
    • Top 500 Contributor
    • Joined on 09-13-2009
    • Posts 16

    Re: Pass variables to RequestRender

     Ok, Thankyou.

    I ended up using a different solution, so this is not as urgent as my other issue (though I'm sure its something you'll want to fix!)

  • 05-21-2010 2:10 PM In reply to

    Re: Pass variables to RequestRender

     Our team verified there is an issue, we're working on a fix for this now.

     

    thanks,

    Joel

  • 05-25-2010 5:30 PM In reply to

    • Peter
    • Top 500 Contributor
    • Joined on 09-13-2009
    • Posts 16

    Re: Pass variables to RequestRender

    This has became a major annoyance for me. Because of this problem (and this problem: http://developer.myspace.com/Community/forums/t/10014.aspx), I was forced to investigate other ways of displaying external content, with this documentation (http://wiki.opensocial.org/index.php?title=Remote_Data_Requests_%28v0.9%29) as my guide.

    In the end I used makeRequest, and I THOUGHT my app was working, but it appears to only work for those with the app installed. Everybody else just sees a blank screen, which is no good. My code is below, can somebody please tell me where I am going wrong? Essentially I need to be able to do two things:

    1) Detect the owner

    2) Display the appropriate external content, based on the owner's preferences.

    And it must work for logged out viewers.

                <style>
                    #target { overflow:auto; }
                </style>   
                <div id="target"></div>
                <script type="text/javascript">
                    function init() {
                        var req = opensocial.newDataRequest(); 
                        req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), 'owner');
                        req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
                        req.send(viewerResponse);
                    }
                    function viewerResponse(data) {
                        var owner = data.get("owner").getData();
                        var viewer = data.get("viewer").getData();
                        url = 'http://example.com/index.php?view=PROFILE&owner='+owner.getId()+'&viewer='+viewer.getId();
                        navigateApp(url);
                    }
                    function navigateApp(url) {
                        var req_params = new Object();
                        req_params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
                        req_params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
                        var req = gadgets.io.makeRequest(url, signRequestCompleted, req_params);
                    }
                    function signRequestCompleted(data) {
                        var target = document.getElementById('target');
                        target.innerHTML = data.text;
                        target.style.height = 'auto';
                        gadgets.window.adjustHeight();
                        target.style.height = '100%';
                    }
                    function getViewName() {
                        return gadgets.views.getCurrentView().getName();
                    }               
                    function loadPage(url,num) {
                        navigateApp(url);
                        return false;
                    }           
                    function submitForm(url) {
                        var venue = document.getElementById('venue').value;
                        url = url + '&venue=' + venue;
                        navigateApp(url);
                        return false;
                    }
                    gadgets.util.registerOnLoadHandler(init);
                </script>

    I thought that maybe because the viewers ID was unknown, the call to newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER) may have been failing. But removing this made no difference.

    Any help would be greatly appreciated.

     

  • 05-26-2010 4:10 PM In reply to

    • Peter
    • Top 500 Contributor
    • Joined on 09-13-2009
    • Posts 16

    Re: Pass variables to RequestRender

    Any updates on

    a) Passing variables to RequestRender? (http://developer.myspace.com/Community/forums/t/10009.aspx)

    b) Displaying OSML Apps? (http://developer.myspace.com/Community/forums/t/10014.aspx)

    I cannot build XML apps without these issues being addess

    Alternatively, any help with my previous post, about getting my code to work for logged out users, will allow me to deploy a legacy app in the meantime.

    At the moment I am sitting here helpless, while delivery of my app gets later and later.

    Please help.

  • 06-02-2010 3:04 PM In reply to

    Re: Pass variables to RequestRender

     What is the appID for this app? I'd like to look directly. Is it on the profile and canvas where it fails to render for users without it installed?

     

    thanks,

    Joel

Page 1 of 1 (7 items)