How to use Profile 2 with Services? I want to  use Services and Profile 2 together.

Like following json code:

request:

http://localhost/api/user/1


response:

{
  "uid": "3",
  "name": "test1",
  "theme": "",
  "signature": "",
  "signature_format": "filtered_html",
  "created": "1393554511",
  "access": "1393562420",
  "login": "1393562420",
  "status": "1",
  "timezone": "Asia/Chongqing",
  "language": "",
  "picture": null,
  "data": false,
  "roles": {
    "2": "authenticated user"
  },
  "rdf_mapping": {
    "rdftype": [
      "sioc:UserAccount"
    ],
    "name": {
      "predicates": [
        "foaf:name"
      ]
    },
    "homepage": {
      "predicates": [
        "foaf:page"
      ],
      "type": "rel"
    }
  },

  "profile 2 field": "test",
  "profile 2 field2": "test",
  "profile 2 field3": "test",
  "profile 2 field4": "test",
  "profile 2 field5": "test",
  "profile 2 field6": "test"
}


I find some code detail in Services Module :

modules/services/resources/user_resource.inc

/**
 * Get user details.
 *
 * @param $uid
 *   UID of the user to be loaded.
 *
 * @return
 *   A user object.
 *
 * @see user_load()
 */
function _user_resource_retrieve($uid) {
  $account = user_load($uid);
  if (empty($account)) {
    return services_error(t('There is no user with ID @uid.', array('@uid' =&gt; $uid)), 404);
  }

  services_remove_user_data($account);

  // Everything went right.
  return $account;
}


It seems services invoke user_load() method to get user's default information.

So I think:


Can I implement hook_user_load() to load Profile 2 fields?
You can use the Services Views module to expose the Profile 2 data you need.


  Views support for the Services module version 3.x and later.
  
  It has currently two features:
   - Create view based resource creating Services display in a view
   - Execute any view of the system via views resource call
  
  Demo video http://youtu.be/DZEhJKMeR5w