You are here

function blogapi_blogger_get_user_info in Blog API 7.2

Same name and namespace in other branches
  1. 8 modules/blogapi_blogger/blogapi_blogger.module \blogapi_blogger_get_user_info()
  2. 7 blogapi.module \blogapi_blogger_get_user_info()

Service callback for blogger.getUserInfo

1 string reference to 'blogapi_blogger_get_user_info'
blogapi_blogger_services_resources in modules/blogapi_blogger/blogapi_blogger.module
Implements hook_services_resources().

File

modules/blogapi_blogger/blogapi_blogger.module, line 351
Provides Blogger services for BlogAPI

Code

function blogapi_blogger_get_user_info($appid, $username, $password) {

  // Validate the user.
  $user = blogapi_validate_user($username, $password);

  // Reload user without services_remove_user_data to get email
  $user = user_load($user->uid, TRUE);

  // Try to guess the user's first and last name.
  $name = explode(' ', !empty($user->realname) ? $user->realname : $user->name, 2);
  return array(
    'userid' => $user->uid,
    'firstname' => $name[0],
    'lastname' => !empty($name[1]) ? $name[1] : '',
    'nickname' => $user->name,
    'email' => $user->mail,
    'url' => url('user/' . $user->uid, array(
      'absolute' => TRUE,
    )),
  );
}