Welcome Developers!

in

Welcome!

in

PHP Client Library - 2

Last post 04-29-2009 11:29 PM by BaPpY. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-30-2008 3:34 AM

    • BaPpY
    • Top 150 Contributor
    • Joined on 02-05-2008
    • Posts 36

    PHP Client Library - 2

    This REST is actualy made by Jerome PHP Client Library. i fixed couple of errors and i also added example to get 500 frnds and also app frnds.

    myspace-platform.zip

  • 01-12-2009 7:24 PM In reply to

    Re: PHP Client Library - 2

    Thank you very much.

    It's very kind of you to share this code.

    But When i use function currentUser(), i meet an error "Fatal error: Uncaught exception 'Exception' with message '404 ' in Space.php:184 Stack trace: #0 Space.php(143): Space->_do_request('currentuser', Array) #1 Space.php(41): Space->do_request('currentuser') #2 index.php(4): Space->currentUser() #3 {main} thrown in Space.php on line 184".

  • 03-12-2009 2:29 AM In reply to

    • BaPpY
    • Top 150 Contributor
    • Joined on 02-05-2008
    • Posts 36

    Re: PHP Client Library - 2

    this function actually deprecated. If you are using java script . user this get user


        function sendRequest()
         {
            // Get the container and create a new DataRequest object
            var mos = opensocial.Container.get();
            var dr = mos.newDataRequest();
           
            dr.add(mos.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');               

            response = dr.send(requestCallback);
        }

        function requestCallback(response)
        {
               
            if ( response.hadError() == false)
            {       
                var viewerId = response.get('viewer').getData().getId();
                viewerName = response.get('viewer').getData().getDisplayName();
        }

     

     

  • 03-13-2009 9:28 PM In reply to

    Re: PHP Client Library - 2

    hi is this utility not valid anymore? i'm using the official myspace REST API and can retrieve only 20 friends.
  • 04-29-2009 11:29 PM In reply to

    • BaPpY
    • Top 150 Contributor
    • Joined on 02-05-2008
    • Posts 36

    Re: PHP Client Library - 2

    here is the complete example. hope you guys find it useful. 

     

    Canvas surface

    <div id="content"></div>
    <script>

        function sendRequest()
         {
            // Get the container and create a new DataRequest object
            var mos = opensocial.Container.get();
            var dr = mos.newDataRequest();
           
            dr.add(mos.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');               

            response = dr.send(requestCallback);
        }

        function requestCallback(response)
        {
               
            if ( response.hadError() == false)
            {       
                var viewerId = response.get('viewer').getData().getId();
                viewerName = response.get('viewer').getData().getDisplayName();
                var postdata = {
                    user : viewerId,
                    
                };
                params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
                params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postdata);
                params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;        
                
                var url = "http://host/myspace_app/canvasconstruction.php";  
                
                gadgets.io.makeRequest(url, function (response, url, errored){
                    if (typeof response.text != 'undefined' || response.text != '')
                    {            
                        var html = response.text;
                
                        document.getElementById('content').innerHTML = "";                
                        document.getElementById('content').style.display = "block";    
                        document.getElementById('content').innerHTML = html;                
                        gadgets.window.adjustHeight();                
                    }    
                }, params);
                
            }    
        }
    </script>

    //----------------------------------------------------------------------- 

     

    canvasconstruction.php

      require_once('Space.php');
      $key = 'http://www.myspace.com/xxxxx';
      $secret = 'xxxxxxxxxxx';
      $s = new Space($key,$secret);
      $hProfile = $s->profile($_REQUEST['user']);
     
      //getting 500 frnds
      $user_frnd_info = array();
      for ($currentPosition = 1; $currentPosition <= 25; $currentPosition++ )
      {
        $page = $currentPosition;
        $page_size = null;
        $list = null;
        $temp = $s->friends($user,$page,$page_size,$list);

        if ( empty($temp['friends']))
            break;
        else
        {   
            for ($j=0; $j< count( $temp['friends']) ; $j++)
            {
                if ( $temp['friends'][$j]['usertype'] !== 'Application' )
                    $user_frnd_info['friends'][ = $temp['friends'][$j];
            }
        }
      }     

        print_r($user_frnd_info);
        
      //getting 500 app frnds
      $user_frnd_info = array();
      for ($currentPosition = 1; $currentPosition <= 25; $currentPosition++ )
      {
        $page = $currentPosition;
        $page_size = null;
        $list = 'app';
        $temp = $s->friends($user,$page,$page_size,$list);

        if ( empty($temp['friends']))
            break;
        else
        {   
            for ($j=0; $j< count( $temp['friends']) ; $j++)
            {
                if ( $temp['friends'][$j]['usertype'] !== 'Application' )
                    $user_frnd_info['friends'][ = $temp['friends'][$j];
            }
        }
      }  
     
        print_r($user_frnd_info);       

Page 1 of 1 (5 items)