BUILDING A FACEBOOK APP

longtermagonizingInternet και Εφαρμογές Web

13 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

73 εμφανίσεις

BUILDING A FACEBOOK APP


STEP 1


Create a Developers License.



Make sure to take note/record the app id/key

STEP 2.


Understand the methodology


GRAPH API explorer.



PERMISSIONS


ACCESS TOKENS (OAUTH).

Access tokens and
OAuth


An access token is a random string that provides
temporary, secure access to Facebook APIs.


A token identifies a
User
,
App

or
Page

session and
provides information about
granted permissions
. They
also include information about
when the token will
expire

and which app generated the token. Because of
privacy checks, the majority of API calls on Facebook
need to be signed with an access token. All access
tokens are generated with
OAuth 2.0

authentication
and authorization procedures.


Example of
oauth


WHAT IS JSON?


Stands for
JavaScript Object Notation
, and is a
text
-
based
open standard

designed for
human
-
readable

data interchange.



It is derived from the
JavaScript

scripting
language for representing simple
data
structures

and
associative arrays
, called
objects.


JSON is built on two structures:


A collection of name/value pairs. In various languages, this is realized
as an
object
, record,
struct
, dictionary, hash table, keyed list, or
associative array.


An ordered list of values. In most languages, this is realized as an
array
, vector, list, or sequence.



These are universal data structures. Virtually all modern
programming languages support them in one form or another. It
makes sense that a data format that is interchangeable with
programming languages also be based on these structures.



An
array

is an ordered collection of values. An array begins with [

(left
bracket) and ends with ]

(right bracket). Values are separated by
,

(comma).


A
value

can be a
string

in double quotes, or a
number
, or true or false
or null, or an
object

or an
array
. These structures can be nested.


In other words …


It is a very complex object!


It represents and stores data.



Most APIs will allow you to choose to receive
the ‘response data’ in JSON format. This
makes it easier for us to manipulate and
‘read’.

STEP 3.


Implement SDK for
Javascript
.



What is an SDK?



SDK (Software Development Kit)


A Software Development Kit is a package of pre
-
written code that developers can re
-
use in order
to minimize the amount of unique code that they
need to develop themselves.

SDKs can help to
prevent unnecessary duplication of effort in a
development community.


SDK and APIs

So what is the difference between an API and an SDK
?


an API is an interface. It's like the specification of the
telephone system or the electrical wiring in your
house. Anything* can use it as long as it knows how to
interface. You can even buy off
-
the
-
shelf software to
use a particular API, just as you can buy off the shelf
telephone equipment or devices that plug into the AC
wiring in your house.


an SDK is implementation tooling. It's like a kit that
allows** you to build something custom to hook up to
the telephone system or electrical wiring.


FACEBOOK SDK CORE METHODS


Core Methods


FB.init


FB.api


FB.ui


FB.init


Init


Using the method outlined on
facebook

dev

site, the JS SDK is loaded
asynchronously so it does not block loading other elements of your page.


The function assigned to
window.fbAsyncInit

is run as soon as the SDK
source has finished loaded. Any code that you want to run after the SDK is
loaded should be placed within this function and after the call to
FB.init
.
For example, this is where you would
test the logged in status

of the user
or
subscribe to any Facebook events

in which your application is
interested.


See the
FB.init documentation

for a full list of available initialization
options.


By default, for performance, the JS SDK is loaded
minified
. If you are in
development and want an un
-
minified version of the JS SDK, which also
enforce arguments in a stricter way, then turn on the debug argument.


FB.api


Overview


FB.api

makes API calls to the
Graph API

or
Deprecated
REST API
.

Examples


FB.api

( ‘
query
url
’, callback function);



FB.api
('/me', function(response) {
alert(
response.name
); });


Get the 3 most recent
Post Objects

Connected

to (in other
words, authored by) the
Facebook Platform Page Object
:

FB.ui


Overview


FB.ui

is a generic helper method for triggering
Dialogs

which allow the user to take some
action.


Facebook SDK methods


LOGIN/LOGOUT



FB.login()



ask the user to login or request additional permissions


FB.logout()



log the user out (only if the user has authorized your application)


FB.getLoginStatus()



asynchronous method to get the current Facebook login
status of the user


FB.getAuthResponse()



synchronous
accessor

for the current authorization
response record


FB.login()



ask the user to login or request additional permissions


FB.logout()



log the user out (only if the user has authorized your application)


FB.getLoginStatus()



asynchronous method to get the current Facebook login
status of the user


FB.getAuthResponse()



synchronous
accessor

for the current authorization
response record