Skip to content
  • Home
  • Entertainment
    • 4cgandhi
    • pakainfo
    • Sports
    • Make Money
    • Jobs
  • News
    • Insurance
      • Auto Car Insurance
      • Business Insurance
    • Donate
    • California
  • About Us
  • Contact Us
  • Privacy Policy
  • Site Map
  • Terms
Login with Facebook and Twitter

OAuth Login with Facebook and Twitter using PHP

August 13, 2018August 13, 2018 by admin

Today, We want to share with you OAuth Login with Facebook and Twitter using PHP.
In this post we will show you Login with Facebook using PHP, hear for we will give you demo and example for implement.In this post, we will learn about OAuth Login for Facebook Twitter and Google Plus Using PHP with an example.

Login with Facebook and Twitter using PHP

There are the Following The simple About OAuth Login with Facebook and Twitter using PHP Full Information With Example and source code.

Steps 1 : Download HybridAuth PHP library

Steps 1: first of all We have simple used redymate library such as a HybridAuth Library with this step by step fully working example, Therefor you simple here need all the source code download HybridAuth PHP library from here all source code on Github.

Steps 2 : Create Facebook and Twitter developer Account

Now, Steps 2: You some legaly should to retrive main social Developer main API(OAuth – authentication) Key as well as get Secret from your Developer accounts created and get all config data in Facebook and Twitter for Login with Facebook and Twitter using PHP.

READ :  Laravel Disable Views Cache programmatically Script

Steps 3 :config for Twitter with Facebook

Steps3: And then you should to make simple changes config.php as well as put here below source code to this file.

$config =array(
"base_url" => "https://infinityknow.com/demo/login-with-facebook-twitter-php/hybridauth/index.php",
"sources" => array (
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "Inf454nityPak574infops5SSkd", "secret" => "Inf454nityPak574infops5SSkd" ),
),
"Twitter" => array (
"enabled" => true,
"keys" => array ( "key" => "Inf454nityPak574infops5SSkd", "secret" => "Inf454nityPak574infops5SSkd" )
),
),
"debug_mode" => false,
"debug_file" => "",
);

Auto Post Tweets on Twitter via API Using PHP

Steps 4 : Facebook and Twitter Login(index.php)

Steps 4: and then make a simple main root file name index.php as well as put the below source code.

E-junkie: Sell digital downloads online

E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

Also see:

  1. The Top 10+ Best Webinar Software Platforms For 2020-2021
  2. Build Your Future Godaddy Careers And Jobs
  3. Introduction To Web Hosting Services

<div align="center">
<a href="login.php?source=Facebook"><img src='https://infinityknow.com/images/facebook.png'></img></a> <br><br>
<a href="login.php?source=Twitter"><img src='https://infinityknow.com/images/twitter.png'></img></a> <br><br>
</div>

Steps 5 : Login with Facebook and Twitter

Steps 5: Now, You will should to make new login.php as well put The below source code.

READ :  How to check request is ajax or not in Laravel 6?

<?php
//PHP start session
session_start();
include('config.php');

//Include path of hybridauth Library
include('hybridauth/Hybrid/Auth.php');

//check proviedes
if(isset($_GET['source'])) {
$source = $_GET['source'];
try {
$hybridauth = new Hybrid_Auth( $config );
$authProvider = $hybridauth->authenticate($source);
$scoial_profile = $authProvider->getUserProfile();
if($scoial_profile && isset($scoial_profile->identifier)) {
echo "<b>Your Name</b> :".$scoial_profile->displayName."<br>";
echo "<b>Img URL</b> :".$scoial_profile->profileURL."<br>";
echo "<b>Your Image</b> :".$scoial_profile->photoURL."<br> ";
echo "<img src='".$scoial_profile->photoURL."'/><br>";
echo "<b>Your Email Address</b> :".$scoial_profile->email."<br>";
echo "<br> <a href='logout.php'>Logout</a>";
}
}
catch( Exception $e ) {
switch( $e->getCode() ) {
case 0 : echo "Unspecified some stuck error."; break;
case 1 : echo "Hybridauth libs configuration error."; break;
case 2 : echo "Provider not good configured."; break;
case 3 : echo "Unknown or disabled source."; break;
case 4 : echo "Missing source any devloper application credentials."; break;
case 5 : echo "Authentication failed. "
. "The clients has canceled the web authentication or the source refused the main connection.";
break;
case 6 : echo "clients your request failed. Most likely the clients is not connected "
. "to the source and he should to authenticate again.";
$twitter->logout();
break;
case 7 : echo "clients not connected to the source.";
$twitter->logout();
break;
case 8 : echo "Provider does not proviedes this feature."; break;
}
echo "<br /><br /><b>Original error message:</b> " . $e->getMessage();
echo "<hr /><h3>Trace</h3> <pre>" . $e->getTraceAsString() . "</pre>";
}
}
?>

Step 6 : Logout with Facebook and Twitter

Steps 6:Last step to make file name logout.php with the below some source code to handle your all the pages not access with logout functionality.

READ :  how to install PHP Accelerator in Xampp

<?php
//PHP session start
session_start();
session_destroy();
header("Location: index.php");
?>

Read :

  • Technology
  • Google Adsense
  • Articles

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Login with Facebook and Twitter.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Categories PHP, Technology Tags Facebook, facebook developer, FacebookAPI, Login, SDK, Twitter, Twitter developer Leave a comment
Post navigation
JavaScript Display Random Image website
PHP MySQLi Star Rating System using Ajax Jquery
  • whatismyscreenresolution
  • tamilrockers new link 2019 free download
  • tamilrockers website link
  • tamilrockers new link 2019
  • tamilrockers url
© 2021 InfinityKnow • Powered by GeneratePress
Scroll back to top
↞
↠