MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

oAuth Iframe php way harder then it should be.

Last post 10-30-2009 11:55 AM by Harakiro. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 10-09-2009 10:46 AM

    oAuth Iframe php way harder then it should be.

    I have been working on making an already exsiting app in facebook ported over to Myspace. everything works - except pulling information from Myspace - names, friends etc.

    I have spent well over 4 full days reading documentation - trying diffrent api's , making request by hand and I'm telling you this is way more fustrating then it needs to be. Seems to work fine with dev tools, but has NEVER worked when using the same string from the Iframe target.

    Looks like some major changes in api have taken place in the last few weeks/months. new api's no longer work. myspaceAPI isn't working. and I'll I can get from sending a well defined url to api.myspace.com is 401 / unauthorized.

    I'm about ready to give up. There is no one spot to look at samples, and NONE of them work. Where are we at with IFrame apps? Are they just not doable at this time?

    I also believe as many have pointed out - that sending server URL's all over the place to pass info it is stupid.

    After 4 days - I am yet to display the "Display Name" associated with the logged in userid.

    does anyone have code that works in IFrame - displaying Names and friends in php?
  • 10-09-2009 12:38 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

     I have been going threw the some headach.  I finally got somewhere.  I am able to get the users ID, Name, and URL.  Then send it to my php.  My problem is getting the friends into my app.  I am not surehow to post code on this forum though.

  • 10-09-2009 12:40 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

     <div id="AppBody" scrolling="no" style="width: 960px; min-height:1000px; overflow:auto; float:left;"> </div>
    <div id='heading'></div>
    <hr size="1px" />
    <script type="text/javascript">
       
        function makeGetRequest(url) {
            var params = new Object();
            params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
            var k = gadgets.io.makeRequest(url, response, params);
        }
       
        function makePostRequest(url, postData) {
            var params = new Object();
            var d = new Date();
            postData = gadgets.io.encodeValues(postData);
            params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
            params[gadgets.io.RequestParameters.POST_DATA] = postData;
            var k = gadgets.io.makeRequest(url, response, params);
        }
       
        function response(dataObj) {
            var newData = dataObj.text + "</br>";
            document.getElementById("AppBody").innerHTML = newData;
        }
       
        var data = {
            data1 : "test",
            data2 : 123456
        };
       
        

    var os;
    var dataReqObj;
    var heading = "111";
    var iddd = "222";
    var thumb = "333";
    function init() {
        os = opensocial.Container.get();
        dataReqObj = os.newDataRequest();
    var OWNERReq = os.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER, opensocial.Person.Field.ID);   
        dataReqObj.add(OWNERReq, "opensocial.Person.Field.ID");
        dataReqObj.send(viewerResponse);

    }
     function viewerResponse(data) {
        var viewer = data.get("opensocial.Person.Field.ID").getData();
     iddd = viewer.getField(opensocial.Person.Field.NICKNAME);
    thumb = viewer.getField(opensocial.Person.Field.THUMBNAIL_URL);   
    heading =  viewer.getField(opensocial.Person.Field.ID);
    heading =   heading.replace(/myspace.com:/, "");
     document.getElementById('heading').innerHTML = "Loading App..."
    var url = "YOUR URL HERE.php?id=" + heading + "&name=" + iddd + "&url=" + thumb;
    window.onload(makeGetRequest(url));
     }

    init();



    </script>

  • 10-09-2009 2:54 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

    I was really trying to avoid using dual languages. I thought going right to REST JSON I could get anything I needed without java. Ah well.. guess It's time to either abandon for now, and wait for the api to work - or learn some Java. Thanks for the code snip - how long did it take to get you there?
  • 10-09-2009 3:42 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

    Yeah I didnt want to really use java either.  But I relized it was the eistest way since Myspace lack good documentation.  It took me bout a week to figure it out.  Still have no clue how to get the friends though.  All the sample codes I have tried fail.
  • 10-12-2009 11:15 AM In reply to

    • Chak
    • Top 50 Contributor
    • Joined on 01-13-2008
    • Posts 70
    • MDP Team

    Re: oAuth Iframe php way harder then it should be.

    Hi, Here's some PHP code to get you started: http://cnanga.com/iframe_php/iframe_php.zip 1.Download the zip file onto your server and edit the MySpace\ckeynsecret.php by adding your app's consumer key/secret. 2. Make sure you've chosen the "External IFrame" radio button option in the "Canvas Surface" tab of the (when editing the app source). Also, make sure to enter the URL to the unzipped code in the "External IFrame URL" field. When the canvas surface for the app is opened, canvas for the app is rendered in an iframe who's source will be set to the URL you entered in Step 2 above. The PHP code (that you unzipped/deployed) will be executed which will pull the user's profile info and friend list Chak
    Filed under:
  • 10-12-2009 12:26 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

     this still dont work.  I get "Remote and Local signatures do not match".  I copied and pasted the key and secret so they cant be wrong.   

  • 10-12-2009 1:21 PM In reply to

    • Chak
    • Top 50 Contributor
    • Joined on 01-13-2008
    • Posts 70
    • MDP Team

    Re: oAuth Iframe php way harder then it should be.

    Interesting that I've got the exact code I gave you working fine on my test server. Can you please print out the remote signature and local signature values? Wondering if it's an url encoding issue Thanks Chak
  • 10-12-2009 4:19 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

     Clark I am not sure exactly what ur asking me for.  Can you please specify where I get this from.  Thanks for your help

     

    Edit I just edited the index.php to display the local and remote sig in the error message.

     

    remote sig = "kXTQ5aIrw3yBVUhzPZuLzi6X7AA="

    local sig = "oUmJvpV535fHc6kyFKYevM1rYls="

  • 10-13-2009 8:29 AM In reply to

    Re: oAuth Iframe php way harder then it should be.

     I skipped the part thatcompared the remote sig and local sig and now am able to load my info and my first 20 friends.  I still want to be able to chekc the sig so I can keep my server secure.

     

    Now the problem is I can only get the first 20 friends even when i use  page=5&page_size=10.

     

     function friendsURL($userid) { return self::$MS_API_ROOT.'/v1/users/'.$userid.'/friends.json?list=applist&page=5&page_size=10'; }

     

    Please help me so I can load all the friends.  Only 20 friends would not make a very good social app.

  • 10-14-2009 10:12 AM In reply to

    • Chak
    • Top 50 Contributor
    • Joined on 01-13-2008
    • Posts 70
    • MDP Team

    Re: oAuth Iframe php way harder then it should be.

    Hi Michael:

     To get all the friends, just specify "page_size=all" and skip the other params.

    Here's the documentation for this API: http://wiki.developer.myspace.com/index.php?title=GET_v1_users_userId_friends_list_page_show

     Also, i'm not really sure why your signatures are not matching up. Can you please post your consumer *key* (not secret :-) )

     Thanks

    Chak

     

  • 10-14-2009 10:16 AM In reply to

    Re: oAuth Iframe php way harder then it should be.

    The API you use for this sample, is "outdated" according to the Myspace wiki. I think Myspace has some developer issues to work out - I'll come back in a few months.
  • 10-14-2009 11:11 AM In reply to

    Re: oAuth Iframe php way harder then it should be.

     Chak,  I tried "page_size=all" and it does nothing. Am I editing it in the right part?  I am editing the myspace.php file.  this line:

     

      function friendsURL($userid) { return self::$MS_API_ROOT.'/v1/users/'.$userid.'/friends.json?page_size=all'; }

     

    my key is "http://www.micdizo.com/iframe"

  • 10-16-2009 12:05 PM In reply to

    Re: oAuth Iframe php way harder then it should be.

     Chak can you please help me solve this issue?  Thanks!

  • 10-19-2009 7:35 AM In reply to

    Re: oAuth Iframe php way harder then it should be.

     Chak,

     

        Please dont let this forum die!  This should be simple answer for you guys to give!

     

    Thanks,

    Mike

Page 1 of 2 (16 items) 1 2 Next >