Pages

Automotive Social Media Reputation Management

Saturday, April 12, 2014

Dealership Website Lead Forms That Automatically Load Using Customer Facebook Information

Create Auto-Populating Lead Forms That Use Customer Facebook Data

TThis is a step-by-step tutorial for allowing you to pre-fill a form on your website with user's Facebook data such as his email, name, address, etc.

In order to get the user's Facebook data, the user has to be logged in your website with his Facebook account.

You need your Facebook app credentials (App ID and App Secret). If you don't have a Facebook app registered or you don't know what that means, go tofacebook.com/developers (I assume you already have a Facebook account) and click on "Set Up New App" and follow the wizard.

Important: make sure you filled "Site URL" and "Site Domain" with your infos. You are given an App ID and an App Secret that we will be using in step 2.


Facebook API Call to Get Customer Profile Data

We are using the Facebook PHP SDK (see on github) to deal with authentication and make API calls.

require "facebook.php";    $facebook = new Facebook(array(      'appId'  => '...',      'secret' => '...',  ));    $user = $facebook->getUser();    if ($user) {    try {      $user_profile = $facebook->api('/me');    } catch (FacebookApiException $e) {      $user = null;    }  }  

Dealer Website Lead Form

<?php if ($user): ?>      <form action="#" method="get">          <input type="text" name="name"              value="<?php echo $user_profile['name'] ?>">          <input type="submit" value="Continue &rarr;">      </form>      <a href="<?php echo $facebook->getLogoutUrl() ?>">          Logout of Facebook      </a>  <?php else: ?>      <a href="<?php echo $facebook->getLoginUrl() ?>">          Login with Facebook      </a>  <?php endif ?>  


Quentin PleplĂ© wrote these instructions for Stackoverflow.



[Sent from Ralph Paglia's iPad]
505.301.6369

No comments:

Post a Comment