App42 introduces a new Avatar Management API which allows your app user to manage his different avatars. Your app user can create his own avatar using this API or can import from Facebook or from any other web media. App user can change his avatar any time and can access the avatar history anytime.
To demonstrate this feature, we have created a sample using App42 JS APIs and you can download it from here. It can easily be integrated in your existing app using following steps.
Get Started
- Register with App42 platform.
- Go to the dashboard and click on the Create App button.
- Fill all the mandatory fields and check the ACL = true to get your API_KEY and SECRET_KEY.
- Download source code App42-Avatar-Management and unzip it on your machine .
- Edit index.html and put your API_KEY and SECRET_KEY here getting from step #3.
- Save and Run index.html file.
Design Details
App42 ACL enabled apps require app user to be authenticated for making API calls. Hence, this sample requires app user authentication and is being authenticated in .js. Once user is authenticated, he can create, update/import his avatar. Below are the code snippets used in this sample for user avatar management using App42 API.
Create Avatar Using App42
var avatarName = "BigBang";
var userName = "Shashank";
var filePath = document.getElementById("filePath");
var file = filePath.files[0];
var descriptiopn = "DESCRIPTION OF AVATAR";
new App42Avatar().createAvatar(avatarName, userName, file, descriptiopn,{
success: function(object) {
var avatarObj = JSON.parse(object);
},
error: function(error) {
console.log(error);
}
});
Get Current Avatar of User
var userName = "Shashank";
new App42Avatar().getCurrentAvatar(userName,{
success: function(object) {
var avatarObj = JSON.parse(object);
},
error: function(error) {
console.log(error);
}
});
Get All Avatars of Current User
var userName = "Shashank";
new App42Avatar().getAllAvatars(userName,{
success: function(object) {
var avatarObj = JSON.parse(object);
},
error: function(error) {
console.log(error);
}
});
Update Current Avatar
var userName = "Shashank";
var avatarName = "Developer";
new App42Avatar().changeCurrentAvatar(userName, avatarName,{
success: function(object) {
var avatarObj = JSON.parse(object);
},
error: function(error) {
console.log(error);
}
});
Update Avatar From Web URL
var avatarName = "Cloud";
var userName = "Shashnk"
var webUrl = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/c132.132.828.828/s160x160/282591_4785425150214_1852706312_n.jpg"
var descriptiopn = "Developer";
new App42Avatar().createAvatarFromWebURL(avatarName, userName, webUrl, descriptiopn,{
success: function(object) {
var avatarObj = JSON.parse(object);
},
error: function(error) {
console.log(error);
}
});
Import Avatar From Facebook Profile Picture
var avatarName = "game";
var userName = "Shashnk";
var accessToken = "Your Facebook Access Token";
var descriptiopn = "Doing Avatar Management";
new App42Avatar().createAvatarFromFacebook(avatarName, userName, accessToken, descriptiopn,{
success: function(object) {
var avatarObj = JSON.parse(object);
},
error: function(error) {
console.log(error);
}
});
If you have any questions or need any further assistance to integrate this in your App, please feel free to write us at support@shephertz.com
Leave A Reply