views:

217

answers:

2

Any advice on how to get MySpace or Orkut info such as birthdate from a person's profile using OAuth using the OpenSocial PHP Client library?

I am lost on the process, and the tutorials are complicated. Any simple code would be helpful!

Thanks.

+1  A: 

First, you need the PHP Open Social Client.

As shown in the documentation, you will need to create an osapi container, which requires a provider and an authorization object. In the case of MySpace, it would look something like:

$provider = new osapiMySpaceProvider();
$auth = new osapiOAuth2Legged("<consumer key>", "<consumer secret>", "<OpenSocial user ID>");
$osapi = new osapi($provider, $auth);

I'm afraid I have no idea what goes in the auth area, whether it's those actual strings or something that you should already know. I'm sure the page I got it from has more info. But either way, once you have the osapi container, you can then make requests for user info:

   $profile_fields = array(
        'aboutMe',
        'displayName',
        'bodyType',
        'currentLocation',
        'drinker',
        'happiestWhen',
        'lookingFor'
    );

$self_request_params = array(
      'userId' => $userId,              // Person we are fetching.
      'groupId' => '@self',             // @self for one person.
      'fields' => $profile_fields       // Which profile fields to request.
  );

$result = $osapi->people->get($self_request_params), 'self');
Anthony
+1  A: 

Here's a nice tutorial: http://wiki.opensocial.org/index.php?title=Social_Website_Tutorial

beriberikix