I am using Snapchat login kit for the web, I successfully integrated using their documentation and after authentication, it redirects to my desired PHP page, in this page, I am getting two types of variable-
1.token_type 2.access_token
Now I need to get display_name, bitmoji_avatar, and external_id, how can I get this in my PHP page, By the way, I searched Snapchat demo documentation but cannot find one that can be used in my PHP page.
The following code is used to integrate the Snapchat Login kit into my project
<script>
window.snapKitInit = function () {
var loginButtonIconId = "my-login-button-target";
// Mount Login Button
snap.loginkit.mountButton(loginButtonIconId, {
clientId: "my_client_id",
redirectURI: "https://Snapreport.org/Redirect.php",
scopeList: [
"user.display_name",
"user.bitmoji.avatar",
"user.external_id",
],
handleResponseCallback: function () {
snap.loginkit.fetchUserInfo().then(
function (result) {
console.log("User info:", result.data.me);
document.getElementById("display_name").innerHTML =
result.data.me.displayName;
document.getElementById("bitmoji").src =
result.data.me.bitmoji.avatar;
document.getElementById("external_id").src =
result.data.me.externalId;
},
function (err) {
console.log(err); // Error
}
);
},
});
};
// Load the SDK asynchronously
(function (d, s, id) {
var js,
sjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "https://sdk.snapkit.com/js/v1/login.js";
sjs.parentNode.insertBefore(js, sjs);
})(document, "script", "loginkit-sdk");
</script>
and after redirection, I am getting this
Aucun commentaire:
Enregistrer un commentaire