This article describes the various endpoints related to Logout User API. This API is used to logout a user from the currently signed social network.


The API Call

ssmi_social_logout(network_type)

Description: This API is used to log out user from the specified social network.


Request Parameter: network_type

Description: This is the account from which user wants to log out.

 


Call Back Functions

ssmi_social_logout_success(response)


This is the success callback method of the API call. The response object is passed as argument. 


The fields of the response object are as follows:


Name Description

success

True if logout succeeded.

False if logout failed (In case of Facebook, if API is called before the user is logged in)

reason

Reason in case of logout failure.

 

ssmi_social_logout_failure(response)


This is the failure callback method of the API call. The response objects is passed as argument. 


The fields of the response object are:


Name Description
error

Set to true when there is a failure in logout.

Also true when invalid network_type is provided.

reason

Reason for failure.

  • Invalid Network Type
  • Processing Error


Example


Below is the sample code snippet. The snippet contains placeholder code for login handling.


//Code snippet for sample implementation:

var ssmi_social_logout_success = function(response){

 if(response.success == true){

 /*Handle code after user has been logged out from the specified network.

 */

 }

 else{

 /* Code to handle the scenario where user cannot be logged out

 as shopsocially social login is not used for login.

 */

 }

}

var ssmi_social_logout_failure = function(response){

 if(response.error == true){

 /* Handle code in case of logout failure

 */

 }

}


Below are the scenarios and the corresponding API response.


1) If API call succeeds and user is logged out successfully:


Call: ss_mi.ssmi_social_logout('facebook')  

Response: Object { success: true }  

 

2) If API call succeeds and user is not logged out because user was not logged in: 


Call: ss_mi.ssmi_social_logout('facebook')

Response: Object { success: false, reason: "User Facebook session not available" }  

 

3) If API call fails:  


Call: ss_mi.ssmi_social_logout() 

Response: Object { error: true, reason: "Invalid network type" }