my.getOpenUserInfo
Get the basic information about a user. This feature requires the user to deliberately trigger to activate the function. This function is not directly called by the API but rather waits for when the user has activated it by clicking a <button>
component.
Use Attention
You need to set the value of the <button>
component open-type to getAuthorize
. After the user clicks and agrees, you can get the basic information returned by the Open Platform  through the my.getOpenUserInfo() interface.
Parameters
N/A
Success Callback Function
The incoming parameter is of the Object type with the following attributes:
Name | Type | Description |
avatar | String | User avatar image url. |
nickName | String | User nickName. |
gender | String | User gender. "m" is male,"f" is female |
countryCode | String | The  code of the country where  user is located, it should follow ISO 3166-1 alpha-2 code standard |
province | String | The  province where  user is located |
city | String | The  city where  user is located |
Sample Code
<!-- .axml -->
<button
a:if="{{canIUseAuthButton}}"
open-type="getAuthorize"
onGetAuthorize="onGetAuthorize"
onError="onAuthError"
scope='userInfo'>
</button>
Button Property Description
Name | Description |
open-type | getAuthorize(Must have this value). |
scope | userInfo(Must have this value). |
onGetAuthorize | Authorization success callback(We can call the interface for getting information in the callback) |
onError | Authorization failure callback(Including user rejection and system exceptions) |
Get User Basic Information
After the user clicks the consent, the user basic information can be obtained through my.getOpenUserInfo().
// .js
onGetAuthorize(res) {
my.getOpenUserInfo({
fail: (res) => {
},
success: (res) => {
let userInfo = JSON.parse(res.response).response
}
});
}
Return Res Message Format
- An example of a successfully returned message format is as follows:
{"response": "{"response": {"code": "10000","msg": "Success","countryCode": "code","gender": "f","nickName": "XXX","avatar": "https://cdn/images/partner/XXXXXXXX","city": "city","province": "province"}}"}
- An example of a successfully returned message format is as follows:
{"response":"{"response":{"code":"40006","msg":"Insufficient Permissions","subCode":"isv.insufficient-isv-permissions","subMsg": "Insufficient permissions"}}"}