Instagram Login create API allows the user to sign into the online website using their Instagram account without sign up on that website.
instagram login create – Social Media Instagram Login Register PHP Code
also You use the instagram login create access token to get instagram user information such as username, instagram ID, instagram name, instagram picture etc.
Creating a Instagram App
first of all Go to Instagram Developer section
Step 1: Craete Login/ Registration system
Now Add the following source code to “Sign in with Instagram” button.
Login with Instagram
Serever side PHP code
if(isset($_GET['code'])) { try { $myInstaObject = new InstagramApi(); // Get the access token $access_token = $myInstaObject->GetAccessToken(INSTAGRAM_CLIENT_ID, INSTAGRAM_REDIRECT_URI, INSTAGRAM_CLIENT_SECRET, $_GET['code']); // Get user information $data_instagram = $myInstaObject->GetUserProfileInfo($access_token); //print_r($data_instagram); $passcode = $data_instagram['id']; $fullname = $data_instagram['full_name']; $username = $data_instagram['username']; $profilepic = $data_instagram['profile_picture']; $loginwith = "Instagram"; /*Check if the user connected before */ $sql = db_query("select * from user_masters where passcode='".$passcode."'"); $row_total = mysqli_num_rows($sql); if($row_total > 0){ $_SESSION['passcode'] = $passcode; header('Location:dashboard.php'); exit(); } $btnstatus = ""; } catch(Exception $e) { echo $e->getMessage(); exit; } }
Check if the user connected before
$sql = db_query("select * from user_masters where passcode='".$passcode."'"); $row_total = mysqli_num_rows($sql); if($row_total > 0){ $_SESSION['email'] = $email; $_SESSION['passcode'] = $passcode; header('Location:dashboard.php'); exit(); }
The MySql table used in this project
CREATE TABLE IF NOT EXISTS `user_masters` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(50) DEFAULT NULL, `lastname` varchar(50) DEFAULT NULL, `email` varchar(60) DEFAULT NULL, `gender` varchar(10) DEFAULT NULL, `passcode` varchar(100) DEFAULT NULL, `profilepic` varchar(250) DEFAULT NULL, `loginwith` varchar(10) DEFAULT NULL, `status` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
- Login With Facebook And Twitter
- Login With Facebook Using Javascript
- PHP CodeIgniter Twitter Login Steps
I hope you get an idea about instagram login create.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.