Login with facebook and google php script

Login with Facebook and Google is not so much tricky .In this post we will discuss about facebook and google login in php with OAuth2 and at the end of the post you can download the utility( Login with Facebook and Google php script ).login with facebook and google php script free

while i was working on this project i encountered with some errors like:

  • Fatal error: Uncaught exception ‘Google_AuthException’ with message ‘Error fetching OAuth2 access token, message: ‘invalid_grant’
  • Page is not redirect properly during facebook login.

well “Fatal error: Uncaught exception ‘Google_AuthException’” this error was nothing but confliction of google OAuth with facebook login To resolve this we use a two way switch method.
when user login with facebook then we lock Google login and when user login with google then we lock Facebook login.

before Login with Facebook and Google You need to do some task at developer account of facebook and google

At Facebook End

  • Login your facebook.
  • Go To : Facebook Apps.
  • Now create a new apps there, in section Website with Facebook login enter the url where you want the data of Facebook user.
    login with facebook free php script

Now note api key and secret.

At Google end

  • login your google account
  • Go to manage domain
  • Add and verify your domain.after verification your domain will be active.
  • Go to google console.
  • In API Access Menu Create a client id.
  • Now check on web application , Enter your Doman and callback Uri where you want the data of google user.
    login with google phpscript free

Now note api key and secret.

How To Use login with Facebook and Google KIT

  • Open the facebook.config.php
  • Paste your apps id and secret.
require_once dirname(dirname(__FILE__)).'/facebook/facebook.php';

$facebook = new Facebook(array(

'appId' =>'your apps ID',

'secret' => 'App Secret',

'cookie' => true ,

));

?>
  • For google Login open google.config.php
  • paste your site_name,oauth2_client_id,oauth2_client_secret and oauth2_redirect_uri.
global $apiConfig;
$apiConfig = array(

'site_name' => 'enter your domain name',
'oauth2_client_id' => 'client id',
'oauth2_client_secret' => 'client secret',
'oauth2_redirect_uri' => 'redirect uri',
'use_objects' => false,

for local database setup
edit config.php

$host = "your host";
$data_b ="your database name";
$db_user ="db username";
$db_pwd ="db password";

this Login with facebook and google php script is free and can be integrated with mvc system easily.
Now download for free happy coding.

Live Demo Download

cascading dropdown using ajax Php and mysql.

dependent dropdown with ajax and php is very common to use script so I create one script for developers cascading dropdown ajax post is about how to create dependent dropdown with jQuery Mysql Php.I have seen there are many tutorial ,but this tutorial is populate dropdown using ajax with xml. In the example we will take 3 dependent dropdown list

Continue reading “cascading dropdown using ajax Php and mysql.”

URL to Embed Code PHP Script (youtube,vimeo)

This article is about a code to convert url to embed code of youtube and viemo videos. In programming we needs this code for creating plugin or custom code.This article will covers how to convert url into embed code and also get thumbnail of youtube and vimeo videos.
You can see live demonstration of url to embed code generator for vimeo and youtube.

Demo

Beside this you can also customise the embed code such you can set custom height and width, enable autoplay.and the end you can download source code of url to embed code generator.
url to embed code youtube vimeo
The idea is common we need to fetch video id from url in both youtube and vimeo, and after that we creates a custom embed link for both the website.height and width can be customise.Autoplay option seems to works with youtube only.For vimeo you can experiment with code,and let me know.

How to convert url to embed code from youtube url

  1. Get the video id
    $step1=explode('v=', $url);
    $step2 =explode('&',$step1[1]);
    $vedio_id = $step2[0];

     

  2. Create embed url from vedio id
    The iframe src of youtube is http://www.youtube.com/embed/$vedio_id so the embed code would be
    < iframe src="http://www.youtube.com/embed/'. $vedio_id.'" width="320" height="240" frameborder="0">
    For autoplay you use autoplay=1 parameter.
    < iframe src="http://www.youtube.com/embed/'. $vedio_id.'?autoplay=1" width="320" height="240" frameborder="0">
  3. get youtube vedio thumbnail
    you can get thumbnail of any youtube vedio with the url
    Large thumbnail : http://img.youtube.com/vi/$vedio_id/0.jpgSmall thumbnail : http://img.youtube.com/vi/$vedio_id/1.jpg
    and so on…

How to convert url to embed code from vimeo url

  1. Get the video id.
    $vedio_id = str_replace('http://vimeo.com/','',$url);
    

     

  2. Create embed url from vedio id.
    The embed url for vimeo is
    $embedurl = “http://player.vimeo.com/video/”.$vedio_id;
    and iframe code for vimeo would be
    < iframe src="'.$embedurl.'" width="320" height="240" frameborder="0" allowfullscreen="allowfullscreen">
  3. Get vedio thumbnail of vimeo.
    this step is slightly diffrent then youtube in this case we will  read video files in the vimeo server and locate its thumbnail image.

    $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vedio_id.php"));if (!empty($hash) && is_array($hash)) {$thumbnail_str ='';
    
    $fullsize_str = '';
    
    }
    
    

I needed this code when i was creating a wordpress theme for a client
it was a video blog and client need this functionality to its wp admin panel with autoplay control.
you have to add just youtube url and it will automatically generate an embeded video on the front page.there is an option for embed code . you can see demo and download the source code below for free.Hope this thing helps you.Happy coding.

Demo
Download http://buffernow.com/demo/vedio_parser.txt

thanks for url to embed code php function for vimeo thumbnail.

Backup And Restore class Mysql Database Using PHP Script

back up restore with php class
Back up And Restore With PHP

Today I’m going to share with you a very useful script that can create backup of your mysql database and restore it any time you wanted, just as one click recovery of mysql using a php script .

I need to make it because one of my client need this feature in his admin panel So here are the steps to use it.

it take just 5 second for backup and 5 second to restore

Here are some steps you need to take

Continue reading “Backup And Restore class Mysql Database Using PHP Script”