IT technologies and concepts explorer and analyser in the web.

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin

New IT Concepts

Share Your Comments

  • Virtualization - The new technology evelution

    Virtualization, in computing, is the creation of a virtual (rather than actual) version of something, such as a hardware platform, operating system, a storage device or network resources.....

  • http://ittechnologies.blogspot.com/2011/04/common-security-vulnerabilities-in-e.html

    Security Vulnerabilities in E-Commerce Systemin

    Most of these attacks have utilized vulnerabilities that have been published in reusable third-party components utilized by websites, such as shopping cart software and poor design of such websites. Other factor is user awareness of security vulnerabilities.

  • VPN - Virtual Private Network

    VPN is a technology which is making secure private network through the public accessible network infrastructure. Virtual Private Network represent by the short name VPN. ...

  • Saas - Cloud Computing

    The cloud computing : is based on this three concepts. IaaS (Infrastructure as a service), PaaS (Platform as a Service) and SaaS (Software as a Service).

Posted by Priyan Fernando - - 0 comments

STEP 1 - create the redirect_uri page

First, create a simple php script in your local web server, which has the Canvas URL (redirect_uri) you set creating your Facebook App in STEP 3. I set this URL to http://localhost/fb-tokens/. My local web server

Put the following code.


<?php
print_r($_GET);
?>
This code will just print the php $_GET array, in other words what Facebook will pass to you from query string.

STEP 2 - authorize your app (give permissions)

On your browser, give the following url, where client_id is App ID and redirect_uri is the URL defined as Canvas URL
The part &scope=manage_pages,publish_stream of this URL defines thw permissions you will assign to your app.
Read about Facebook permissions:
  • an introduction here.
  • about Facebook publish_stream permission here.
  • about Facebook manage_pages permission here.
The result will be
authorize your app to access your profile
(click the thumb for full image)
click OK
authorize your app to post to your friends on your behalf
(click the thumb for full image)
click OK
authorize your app to manage your Pages
(click the thumb for full image)
Get the code value
(click the thumb for full image)
You will get somenthing like this
1
2
3
4
5
Array
(
[code] =>
AQCnhrD8RSxJRmGJdYCfFD33hGPv84xa-xqXKD1-3i3qmsPjqHODEn1cROQkYv6LSKhKlPBxkPHD9gUs-9W0GSwDJVvarX70QiLAYmcLsGhN2u0Ib1OF512TvMljg8WLjx0FaAFCB1DHiTqYE-6ZNtWqtZpe4aIecOw949QNcWbZOf2BiCH_yECCNfamKdatV5Nv1Oa1IvIi_8_zVGc_cQqujVC_O2Apkzyj7M1cypoucGc02NzpAQv3yPqCnIuz5TWglcvhr2YNL7HAClLW0ydWgmq7FyfXOfrbFLoRjd-GRTevmTCffA2iV_A1i-itStY
)
After getting the code value, give the following url, where client_id is App ID and redirect_uri is the URL defined as Canvas URL, client_secret is App Secret and code is the code got.
(click the thumb for full image)
You will get the Access Token (!)
1
access_token=CAACYHYyWcnIBAJ1LwRLTERQNXJ4qRCqoTf2pgs1V2AiZCOreWAH0bY2UKaoyD3elfcEZAZAs6fZAEYPAZC5OlU6ZCg8Org32D13LiencxZA0PsNzkQPPuZCiZAukgMnqLXM0F2ZBlYZAnZB08qVwOo6DgiCJSlkoZCb9VVs0ARsleZBcduzTQKZBvIcvjLZBXXr5ye8R4FcZD&expires=5183831

STEP 3 - Access Tokens for your Facebook Pages (if any)

If you have any Facebook Pages (except your Personal Profile), you can get Access Tokens for them, using the following URL, where access_token is the Access Token you just got for your Personal Profile
The result will be the following JSON string
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
   "data": [
      {
         "category": "Website",
         "name": "pontikis.net",
         "access_token": "CAACYHYyWcnIBAMK1y2tqiRKx8bBXGFFzjdUamOlMZCBJrTSL8ic1z5sZBarBi3DbTh9mMUz3aiZCAQRNHvOmcMxLZC53FNtkrVCq8rZCLsyjbQVZAt8o7S6Rd1UT0LK7AkgyZAlu11MC9rWND8eZBiKjjiYjwmBMLWko7k6GGPZCREehKRNFCsyM1Ll7sFb1hXycZD",
         "perms": [
            "ADMINISTER",
            "EDIT_PROFILE",
            "CREATE_CONTENT",
            "MODERATE_CONTENT",
            "CREATE_ADS",
            "BASIC_ADMIN"
         ],
         "id": "466400200079875"
      }
   ],
   "paging": {
   }
}
Except of getting Access Token for your Fan Pages, the above step is useful to get your Fan Pages Facebook id. You will need it, when you try to post to your Fan Pages. However, this procedure is described independently (see below: How to Find your Facebook id)

STEP 4 - Check your Access Token

Facebook Access Tokens will expire in about an hour. Access Token obtained with the above procedure are long-lived Access Tokens and will expire after two months (60 days).
offline_access permission, used to prevent tokens expiration, was depreceted since 2012. Read more at https://developers.facebook.com/roadmap/offline-access-removal/.
Since offline access is deprecated you cannot create an access token which doesn’t expire. The best you can get is a long-lived Access Token (expires in 60 days).
So, it is very important to know your Access Token expiration time. Just use the URL
https://developers.facebook.com/tools/debug/access_token
For example, to check (debug) the Access Token obtained for this demo
(click the thumb for full image)
Notice that this Access Token will expire after 60 days.
I remind you that this app (Demo_auto_post_php) has been deleted, so the above URL will not give you the same results. The above screenshot is taken before app deletion.

Renew Access Token after expiration

Facebook long-lived Access Tokens will expire after about two months (60 days). In order your app to remain functioning, you (unfortunately) have to repeat "How to Get Facebook Access Token - STEP 2".

How to Find your Facebook id

The Facebook id of a Personal Profile of Fan Page or Business Page is public information, available using Facebook Graph API. Just use a URL like:
http://graph.facebook.com/username
For example:
To find my Facebook Personal Profile id, use:
http://graph.facebook.com/chr.pontikis
To find Facebook id of my Fan Page (the Fan Page of this blog), use:
http://graph.facebook.com/pontikis.net

You may also use some online tools like http://findfacebookid.com/
[ Read More ]