ChatOnGo for Business: The future of Enterprise Communication

What are one of the biggest challenges that organizations face today? Communication gaps and employee attrition rates within an organization. Organizations can’t afford a high rate in either of these. This makes information management vital. If you don’t disclose proper information about a project to the concerned people, the project might suffer incurring losses for … Read more

Business Travel App Essentials | Plan your business trip

Bussiness travel app: Travelling for business requires careful planning, including managing your reservations, information on flights, and business expense. Such a trip is often very exhausting, since you are torn between business meetings and having time just for yourself. However, being in a rush does not have to be so stressful, especially nowadays, when there … Read more

How To Make Facebook App- Beginners Guide

Making Facebook app help you to earn much more & easy to make for a beginner, but the question is how to make a facebook app. I say making a Facebook app is not so much difficult if you have knowledge of either PHP, ios, android, unity or javascript because these are a different platform in which you can make your app. Now skip extra writing & learn how to make a Facebook app ( By this tutorial beginner also start their app either they are not expert in above mention languages).

 Facebook App tutorial

Different platform for the Facebook app:

  • PHP: This usually normal app making platform by which you can make an app for your own website page, server side app (this mean you can store Facebook data to a server or can take Facebook data from the server), facebook graph API, canvas app. Few Examples of PHP platform app
  • How to Use Facebook API in PHP App.

Facebook Session:

This is a Facebook session which allows you to make a request for Graph API. Validate request by session, Here is session used for:

use Facebook\FacebookSession;
FacebookSession::setDefaultApplication('app-id', 'app-secret');
// If you already have a valid access token:
$session = new FacebookSession('access-token');
// If you're making app-level requests:
$session = FacebookSession::newAppSession();
// To validate the session:
try {
$session->validate();
} catch (FacebookRequestException $ex) {
// Session not valid, Graph API returned an exception with the reason.
echo $ex->getMessage();
} catch (\Exception $ex) {
// Graph API returned info, but it may mismatch the current app or have expired.
echo $ex->getMessage();
}

The above code copy from Facebook developer doc. Let’s have a description on this:-

Few key methods for start session of facebook:

  • SetDefaultApplication: By this set default your Facebook app ID code & App secret code(I hope you know what i am talking about, IF NO CLICK HERE). This information stored in your Facebook account and you validate that in your app for this you need to set Default values of the app. To fetch this information you need to this syntax “SetDefaultApplication”(As in line 2 in above code)
  • Validate: To ensure that above-set default session information valid or not you need this syntax. This syntax check appID & Secret code you enter right or not. Also ensuring that expiring time of app is not passed.
  • newAppSession: This is so much important to start session because this syntax start session according to your app authority from Facebook that means which API enabled in your app(if you do not know about this ,
  • newSessionFromSignedRequest:This finalize your session & return information to signed profile. After all validation, this sends session request from Graph API.
FacebookRequest

This allows you to get session request that you validate in above code. Here you can request for or get information according to your required. Below given code allow these all things with this syntax.

$request = new FacebookRequest(  
  FacebookSession $session,  
  string $httpMethod,  
  string $path, 
  array $params = NULL,
  string $version = NULL
);

 

// Make a new request and execute it.
try {
  $response = (new FacebookRequest($session, 'GET', '/me'))->execute();
  $object = $response->getGraphObject();
  echo $object->getProperty('name');
} catch (FacebookRequestException $ex) {
  echo $ex->getMessage();
} catch (\Exception $ex) {
  echo $ex->getMessage();
}
// You can chain methods together and get a strongly typed GraphUser
$me = (new FacebookRequest(
  $session, 'GET', '/me'
))->execute()->getGraphObject(GraphUser::className);
echo $me->getName();

 

The above code copy from Facebook developer doc. Let’s have a description on this:-

Few key methods for use of Facebook request:

  •  execute (): This basically uses to execute code & return value. This also performs network check for failure issue.  
  • getPath (): This Return a copy of the request.
  • getParameter (): This returns a copy of parameter in the request.
  • getSession (): This return session which associates with the request.

Read more