MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

get_friends() only can retrieve 20 friends?

Last post 03-11-2009 11:37 AM by KushApps. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 09-09-2008 10:43 AM

    get_friends() only can retrieve 20 friends?

    Hi,

    I used get_friends(myspaceid) and only 20 friends' data shown in the result array. Is any way to retrieve all my friends' data?

    Thanks!

  • 09-23-2008 3:10 PM In reply to

    • Matt
    • Not Ranked
    • Joined on 02-05-2008
    • Posts 3

    Re: get_friends() only can retrieve 20 friends?

    I am seeing this as well. For those of us using the PHP REST API provided by myspace, this is a significant bug. Has anyone discovered a workaround for this, or hacked the PHP library itself to get this call to work correctly?

  • 09-23-2008 3:56 PM In reply to

    Re: get_friends() only can retrieve 20 friends?

    I used both the official and unofficial PHP API libraries and saw this same problem.  I took a closer look and it seems as though the page_size parameter needs to be the first argument in the request query string.  I detailed the issue here: http://www.nakedtechnologist.com/?p=79

    I took the unofficial API library and revised the files.  The following changes have been made to it:

    - OAuth.php - I reversed the array merge order in the from_consumer_and_token() function.  This allowed the user defined parameters (and page size) to be the first parameters in the query string after the request URI.

    - Space.php - I modified the friends() function.  I was also having the problem here that the array of parameters was not making it through to the OAuth function.  I updated it a little, changed page_size to be the first one in the array and updated the default values of the function to return all friends.

    So now, when requesting friends you can make the following call:

    $session = new Space(Config::$MS_APPLICATION_KEY, Config::$MS_APPLICATION_SECRET);
    $friend_list = $session->friends('USER_ID',1,'all');

    where the 1 is the page, all is the number of friends to return and, optionally, a 4th parameters is the list.

    You can download the revised zip file directly here: http://www.nakedtechnologist.com/files/ms_unofficial_php_api_with_friend_fix.zip

    I would recommend backing up your existing files since I just made these changes yesterday and have not tested them against all available functionality. 

    Let me know if you run into any issues,

    Jonathan LeBlanc

    Filed under: , , ,
  • 10-06-2008 10:15 PM In reply to

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

    Re: get_friends() only can retrieve 20 friends?

    http://developer.myspace.com/Community/forums/t/2551.aspx 

  • 01-21-2009 6:50 AM In reply to

    • Tamas
    • Not Ranked
    • Joined on 10-16-2008
    • Posts 10

    Re: get_friends() only can retrieve 20 friends?

    Hi,

     Any hope of this being fixed in the official library? I also took a look at the myspace php code and the way it uses OAuth.php is incorrect. It is passing in the page and page_size parameters as part of the url not as distinct parameters. As such, OAuth.php throws away these parameters and they never get submitted to the server. MySpaceAPI.php would need to be restructured for correct OAuth.php use. 

     This is yet another occurrence of incorrect OAuth use. (See also http://developer.myspace.com/Community/forums/t/6362.aspx.) I'd be happy to help out with such issues if there was some context for doing it... Getting in touch with the php developers, or providing more of an open source model where we can check in fixes ourselves wold be great.

     Thanks

    Filed under: , ,
  • 01-21-2009 7:16 AM In reply to

    • Tamas
    • Not Ranked
    • Joined on 10-16-2008
    • Posts 10

    Re: get_friends() only can retrieve 20 friends?

     For those of you still trying to get passed this problem, here is a quick fix:

     In MySpaceAPI.php look for method get_friends and replace this line:

    return $this->do_get($resource . $paging, null);

     with this one:

    return $this->do_get($resource, array('page' => $page, 'page_size' => $page_size, 'list' => $list));

     It's not pretty but will work fine. It makes MySpaceAPI.php pass query string parameters in to OAuth.php as parameters, not as part of the base url.

    Thanks

    Filed under: ,
  • 03-10-2009 10:18 PM In reply to

    Re: get_friends() only can retrieve 20 friends?

    thanks it works...to fellow developers...make sure to set the page and page_size in this case. I used 1 and 500...perfect thx!
  • 03-11-2009 11:37 AM In reply to

    Re: get_friends() only can retrieve 20 friends?

    actually this only gets me 100
Page 1 of 1 (8 items)