facebook graph api code example

Example 1: facebook integration api

DB Structure for fb : 
========================

Table Structure : 
---------------------------

fb_user :  id, user_id, fb_user_id, access_token, data_access_expiration, expires_In, signed_Request, date_preset, created_at, updated_at
---------
fb_user_pages :  id, fb_user_id, page_id, page_name, access_token, category, tasks, created_at, updated_at
---------------
fb_page_insights :  id, fb_page_id, created_date, page_post_engagements, page_views_total, page_fan_adds_unique, page_impressions, created_at, updated_at
------------------
fb_page_posts :  id, fb_page_id, post_id, message, created_date, likes, comments, shares, post_reach, post_engagement, created_at, updated_at
---------------

Example 2: graph api facebook google script

function getFbService() {
  // Create a new service with the given name. The name will be used when
  // persisting the authorized token, so ensure it is unique within the
  // scope of the property store.
      return OAuth2.createService('Facebook')
    // Set the endpoint URLs.
    .setAuthorizationBaseUrl('https://www.facebook.com/dialog/oauth')
    .setTokenUrl('https://graph.facebook.com/v2.6/oauth/access_token')
    // Set the client ID and secret, from the Google Developers Console.
      .setClientId('...')
      .setClientSecret('...')
    // Set the name of the callback function that should be invoked to complete
    // the OAuth flow.
    .setCallbackFunction('authCallback')
    // Set the property store where authorized tokens should be persisted.
    .setPropertyStore(PropertiesService.getUserProperties());
}

Tags:

Go Example