MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

makeRequest

Last post 04-02-2008 6:28 PM by Jeremy. 36 replies.
Page 1 of 3 (37 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 01-14-2008 4:34 PM

    • robby
    • Top 200 Contributor
    • Joined on 01-09-2008
    • Posts 13
    • MDP Team

    makeRequest

    Is there documentation for the makeRequest function? Also, can it call webservices?

  • 01-15-2008 10:11 AM In reply to

    • Chad
    • Top 500 Contributor
    • Joined on 01-03-2008
    • Posts 8
    • MDP Team

    Re: makeRequest

    Hey, there's not really any official documentation yet, but see the comments in MyOpenSpace.js and opensocialreference.js for more info.  And yes, you can call web services.

    Comments below:

    /**
     * Fetches content from the provided URL and feeds that content into the
     * callback function.
     * @param {String} url The URL where the content is located
     * @param {Function} callback The function to call with the data from the URL
     *     once it is fetched
     * @param {Map.<opensocial.ContentRequestParameters, Object>} opt_params
     *     Additional parameters to pass to the request
     *
     * @private
     */

     /**
     * makeRequest implementation using proxy
     * Fetches content from the provided URL and feeds that content into the callback function
     * @param {String} url The URL where content is located
     * @param {Function} callback The function to call with the data returned from url
     * @param {opensocial.ContentRequestParameters} Additional parameters to pass to the request
     */

     

  • 01-22-2008 10:19 AM In reply to

    • Allen
    • Top 150 Contributor
    • Joined on 12-26-2007
    • Posts 24
    • MDP Team

    Re: makeRequest

    All, Chris (Holmok) send me this great sample code to get makeRequest working ... Allen --------------------------
    waiting....
    function init() { var target = document.getElementById('target'); try{ opensocial.Container.get().makeRequest( "http://www.fuali.com/crap.html", function(content, errored) { if (!errored) {target.innerHTML = content.responseText;} else {target.innerHTML = 'error';} }, opensocial.ContentRequestParameters.MethodType.GET); } catch(er){ target.style.backgroundColor = '#f00'; target.style.color = '#fff'; target.innerHTML = er.message; } } init(); --------------------------
  • 01-22-2008 10:32 AM In reply to

    • Fuali
    • Top 200 Contributor
    • Joined on 01-12-2008
    • Posts 13

    Re: makeRequest (MORE PRETTY)

    <div id="target" style="padding:10px;">
    waiting....
    </div>
    
    <script type="text/javascript">
    
    
    function init() {
        
    	var target = document.getElementById('target');
    	try{
    	    opensocial.Container.get().makeRequest(
    			"http://www.fuali.com/crap.html", 
    			function(content, errored) 
    			{
    				if (!errored) {target.innerHTML = content.responseText;}
    				else {target.innerHTML = 'error';}
    			}, opensocial.ContentRequestParameters.MethodType.GET);
    		
    	}
    	catch(er){
    		target.style.backgroundColor = '#f00';
    		target.style.color = '#fff';
    
    		target.innerHTML = er.message;	
    	}
    }
    init();
    
    </script>
    
  • 01-22-2008 10:41 AM In reply to

    • nick
    • Not Ranked
    • Joined on 12-27-2007
    • Posts 2

    Re: makeRequest

    Currently, makeRequest is only returning uncompressed responses.  You can test makeRequest on my profile  http://www.myspace.com/ktrout.  The URL in chris's sample as well as www.yahoo.com  will return results.  However, something like a google search or www.askmen.com  will just error out.  The API team is aware of this and should have the issue resolved soon.
  • 01-23-2008 4:19 PM In reply to

    Re: makeRequest

     One quick note regarding callbacks...

     

    After this most recent push, the signature is now makeRequest_callback(content, url, error)

    content will be based on your CONTENT_TYPE, so could be an XMLDocument, string, or MyOpenSpace.Feed.RSS2 (so far I've only written RSS2.0 support).

    The idea behind passing back url is you can reuse callbacks based on url.  If more finite control is needed, ask for it here =)

     

    Cheers,

    Max 

  • 01-30-2008 11:37 AM In reply to

    • Alex
    • Not Ranked
    • Joined on 01-30-2008
    • Posts 1

    Re: makeRequest

    Any eta on a fix for makeRequest?  I'm getting runtime errors from relay.proxy for most sites 

  • 01-30-2008 1:30 PM In reply to

    • Xavier
    • Top 500 Contributor
    • Joined on 01-30-2008
    • Posts 5

    Re: makeRequest

    I have been trying to do write an RSS feed reader, but I am getting an errorCode of "unauthorized". 

    <div id="divHello"></div>
    <script type="text/javascript">
    function processFeed(feed) {
    var html= "";
    html += "Feed object properties: "
    for (property in feed) {
    html += "<br>" + property;
    }
    if (feed.errorCode) {
    html += "<br>errorCode: "+feed.errorCode;
    html += "<br>errorMessage: "+feed.errorMessage;
    } else {
    // Access the fields in the feed
    html += "<b>" + feed.Title + "</b>";
    html += "" + feed.Description + "<br>";
    alert(feed.Title);
    alert(feed.Description);
    }
    document.getElementById('divHello').innerHTML = html;

    }
    opensocial.makeRequest("http://www.myblog.com/rss", processFeed, {'method':'GET','contentType':'feed','numEntries':'5','getSummaries':'true'});
    </script>

     Is this the right way to do this?  I am assuming that this is the bug everyone is referring to.

     

  • 01-30-2008 2:14 PM In reply to

    • Eric
    • Top 500 Contributor
    • Joined on 01-30-2008
    • Posts 5

    Re: makeRequest

    xavierstevens:

    I have been trying to do write an RSS feed reader, but I am getting an errorCode of "unauthorized". 

    <snip/>

     Is this the right way to do this?  I am assuming that this is the bug everyone is referring to.

     

    I am running into multiple error messages from the "relay.proxy" that makeRequest is using. 

    http://api.msappspace.com/relay.proxy?opensocial_token=MIGvBgorBgEEAYI3WAOCoIGgMIGdBgorBgEEAYI3WAMBoIGOMIGLAgMCAAECAmYDAgIAwAQIX7VU6HEggv4EEA%2Fjf5ui4R3jtZ6pHaKETk0EYBEnnWKIek2lQ7ZDsxhxDHA6GdYdpTBXn8EMH%2BVRsSAqlWS8BQX731Cn%2FEWtpeoL35D5PCWMM6jVdI0IfcY5lj4gK11oUxdxwKMwBd28SLtNDy5ibwuvu8Dd3Q1Wqh%2F4kg%3D%3D&opensocial_url=http://www.myspace.com/ktrout 

    is returning

    <error xmlns="api-v1.myspace.com"><statuscode>401</statuscode><message>Not an OpenSocial resource.</message></error>

    or sometimes "Runtime Error" 

  • 01-30-2008 5:30 PM In reply to

    Re: makeRequest

    Hi all, we're working on getting makeRequest up and running right now, it'll hopefully be fixed shortly.


    Thanks,

    Chad 

  • 01-30-2008 6:26 PM In reply to

    Re: makeRequest

     WRT Feed capabilities via makeRequest(), we currently support RSS2 and are working on ATOM feeds.  That said, we are currently doing the paging/summarization on the client and that just won't do.  In the meantime, just expect the XHR to take a little while longer than the expected content in your callback should take.

     

    Cheers,

    Max 

    Filed under: , , ,
  • 01-30-2008 6:46 PM In reply to

    Re: makeRequest

     makeRequest has been pushed to production (not the ATOM bits), so please try your FEED content request again.

     

    Cheers,

    Max 

  • 01-30-2008 6:49 PM In reply to

    Re: makeRequest

     OK... it was fixed than busted. fixed... then busted....

    Long story short: "We gotz it working better than ever!"

    Big thanks to Paul Walker, Haider and Max Newbould to get this thing at it's best.

    Filed under:
  • 01-31-2008 5:31 PM In reply to

    • Xavier
    • Top 500 Contributor
    • Joined on 01-30-2008
    • Posts 5

    Re: makeRequest

    I posted this in the bugs topic as well. I have found that some feeds don't work.  This could be because they have 
    ATOM tags in them as well as RSS 2.0.  I also noticed that the NUM_ENTRIES parameter for makeRequest on a feed doesn't 
    seem to have any effect.  It always gives me the default number of 3 posts.
     
    Here is my code:
    <div id="rssFeedContainer"></div>
    <script type="text/javascript">
    function processFeed(feed, url, error) {
    var html = "";
    if (!error) {
    for (var i=0; i < feed.items.length; i++) {
    var title = feed.items[i].title;
    var desc = feed.items[i].description;
    html += "<div><b>" + feed.items[i].title + "</b></div>";
    html += "<div>" + feed.items[i].description + "</div><br>";
    }
    } else {
    html += "<br>Error when fetching url: " + url;
    }
    document.getElementById('rssFeedContainer').innerHTML = html;
    }

    function init() {
    var rssContainer = document.getElementById('rssFeedContainer');
    try {
    params = {};
    params[opensocial.ContentRequestParameters.METHOD] = opensocial.ContentRequestParameters.MethodType.GET;
    params[opensocial.ContentRequestParameters.CONTENT_TYPE] = opensocial.ContentRequestParameters.ContentType.FEED;
    params[opensocial.ContentRequestParameters.NUM_ENTRIES] = '5';
    opensocial.Container.get().makeRequest("http://exported.tumblr.com/rss", processFeed, params);
    } catch (e) {
    rssContainer.innerHTML = e.message;
    }
    }
    init();
    </script>  
     
    Example feeds that do work:
    Tumblr feeds
     
    Example feeds that don't work: 
    MySpace Developer Forum Feeds
    Wordpress feeds
    Feedburner feeds
  • 02-05-2008 2:01 AM In reply to

    • joe
    • Not Ranked
    • Joined on 02-05-2008
    • Posts 2

    Re: makeRequest

    I was just trying this sample code verbatim from the opensocial api docs:

     

        <div id="content_div"></div>
        <script type="text/javascript">
          opensocial.makeRequest("http://www.google.com",
            function(response) {              
            var html = response.substr(0,400); 
            document.getElementById('content_div').innerHTML = html;
          }, {'method' : 'GET', 'contentType' : 'html'});
        </script>

     

    Any reason why this does not work?

     

     

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