PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Overview
  • The elements proposed by WLanguage
  • Declaring the application in Facebook
  • Declaring the WEBDEV site in Facebook
  • Implementing the Facebook identification in the WINDEV or WINDEV Mobile application or in the WEBDEV site
  • Establishing the connection
  • Using the Facebook API
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
Facebook, 1st social network in the world, is very much used by the companies to group their customers. Facebook includes a very powerful API to efficiently exploit the platform.
WINDEV, WEBDEV and WINDEV Mobile (for the Android and iOS applications) propose two modes for using Facebook:
  • a simple use, where the Facebook login of user can be used to identify in the WINDEV or WINDEV Mobile application or in the WEBDEV site. The end user will have less passwords to remember.
  • an advanced use, allowing you to interface with Facebook in order to use the Facebook API from a WINDEV or WINDEV Mobile application or from a WEBDEV site.
The principle is the same regardless of the selected use mode. You must:
  • Declare the WINDEV or WINDEV Mobile application or the WEBDEV site to Facebook.
  • Use the Facebook identifiers in the WINDEV or WINDEV Mobile application or in the WEBDEV site.
  • Connect to Facebook from the WINDEV or WINDEV Mobile application or from the WEBDEV site to identify the user.
For an advanced use, several WLanguage functions allow you to communicate with Facebook via its API.
Versions 22 and later
WEBDEV - Server codeLinux This feature is now available for WEBDEV sites in Linux.
WEBDEV - Server codeWindows This feature is now available for WEBDEV sites in Windows.
Caution: This feature is not available for the WINDEV applications in Linux.
New in version 22
WEBDEV - Server codeLinux This feature is now available for WEBDEV sites in Linux.
WEBDEV - Server codeWindows This feature is now available for WEBDEV sites in Windows.
Caution: This feature is not available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This feature is now available for WEBDEV sites in Linux.
WEBDEV - Server codeWindows This feature is now available for WEBDEV sites in Windows.
Caution: This feature is not available for the WINDEV applications in Linux.
The elements proposed by WLanguage
The following WLanguage elements can be used to communicate with Facebook:
Declaring the application in Facebook
Versions 22 and later
WEBDEV - Server code

Declaring the WEBDEV site in Facebook

A Facebook application must be created beforehand.
Let's see the steps to follow (valid at the time this page was written):
  1. Connect to the "https://developers.facebook.com/" site.
  2. Identify yourself ("Connection" button).
  3. Register yourself if necessary (click the "Register" button and follow the wizard).
  4. In "My Apps", click "Create App".
  5. In the popup that appears, select "Consumer".
  6. Click "Next".
  7. In the popup that is displayed, specify:
    • In "App Display Name", enter the name of the application.
    • In "App Contact Email", enter a valid email address.
  8. Confirm the app creation (and validate the security check, if necessary).
  9. The page of the application that was just created is displayed.
  10. Then, click the "Settings" menu and choose "Basic".
  11. Note down the "App ID" and "App Secret".
At this time, you have the ability to connect to the site with the Facebook user who declared the application (his administrator by default).
To use other users for the tests, click the "Roles" menu and add the users with the relevant rights (developers, testers, ...). You also have the ability to create users for test ("Test users" tab) without using the existing Facebook accounts
For a real use of the application, the application must be made public and it must be submitted to Facebook if necessary ("Review apps" options). For more details, see the Facebook documentation.
New in version 22
WEBDEV - Server code

Declaring the WEBDEV site in Facebook

A Facebook application must be created beforehand.
Let's see the steps to follow (valid at the time this page was written):
  1. Connect to the "https://developers.facebook.com/" site.
  2. Identify yourself ("Connection" button).
  3. Register yourself if necessary (click the "Register" button and follow the wizard).
  4. In "My Apps", click "Create App".
  5. In the popup that appears, select "Consumer".
  6. Click "Next".
  7. In the popup that is displayed, specify:
    • In "App Display Name", enter the name of the application.
    • In "App Contact Email", enter a valid email address.
  8. Confirm the app creation (and validate the security check, if necessary).
  9. The page of the application that was just created is displayed.
  10. Then, click the "Settings" menu and choose "Basic".
  11. Note down the "App ID" and "App Secret".
At this time, you have the ability to connect to the site with the Facebook user who declared the application (his administrator by default).
To use other users for the tests, click the "Roles" menu and add the users with the relevant rights (developers, testers, ...). You also have the ability to create users for test ("Test users" tab) without using the existing Facebook accounts
For a real use of the application, the application must be made public and it must be submitted to Facebook if necessary ("Review apps" options). For more details, see the Facebook documentation.
WEBDEV - Server code

Declaring the WEBDEV site in Facebook

A Facebook application must be created beforehand.
Let's see the steps to follow (valid at the time this page was written):
  1. Connect to the "https://developers.facebook.com/" site.
  2. Identify yourself ("Connection" button).
  3. Register yourself if necessary (click the "Register" button and follow the wizard).
  4. In "My Apps", click "Create App".
  5. In the popup that appears, select "Consumer".
  6. Click "Next".
  7. In the popup that is displayed, specify:
    • In "App Display Name", enter the name of the application.
    • In "App Contact Email", enter a valid email address.
  8. Confirm the app creation (and validate the security check, if necessary).
  9. The page of the application that was just created is displayed.
  10. Then, click the "Settings" menu and choose "Basic".
  11. Note down the "App ID" and "App Secret".
At this time, you have the ability to connect to the site with the Facebook user who declared the application (his administrator by default).
To use other users for the tests, click the "Roles" menu and add the users with the relevant rights (developers, testers, ...). You also have the ability to create users for test ("Test users" tab) without using the existing Facebook accounts
For a real use of the application, the application must be made public and it must be submitted to Facebook if necessary ("Review apps" options). For more details, see the Facebook documentation.
Implementing the Facebook identification in the WINDEV or WINDEV Mobile application or in the WEBDEV site

Establishing the connection

To connect to Facebook, you must:
  1. Configure a Facebook session (fbSession variable). In the different proprerties of this variable, you must specify:
    • WEBDEV - Server code the "App ID" and the "App Secret" supplied when registering the application to Facebook.
  2. Establish the connection with FBStartSession.
For example:
MaConnexion is fbSession
// Paramétrage de la session
MaConnexion.AppID = "1664XXXXXXXXXXXX"
MaConnexion.AppSecret = "c6e7XXXXXXXXXXXXXXXXX"
// Définition des droits:
// - Lecture de l'email
// - Gestion des pages
MaConnexion.Permission = [fbEmail, "manage_pages", "publish_pages", "publish_actions"]
// Connexion
FBStartSession(MaConnexion)
If the connection is permanent, the function presents no connection screen and the session is started directly.
Remarks:
  • WEBDEV - Server code A Web page is displayed in the default browser, allowing the user to type his login and password.
  • A started Facebook session is a persistent session: it will remain opened:
    • until the application is closed.
    • until the call to FBStopSession.

Using the Facebook API

FBRequest is used to perform requests toward Facebook.
The following example is used to list the pages and groups managed by the current user:
sURL is string ANSI = GRAPHAPI + "me/accounts?locale=fr_FR"
sJSON is string ANSI
vJSON is Variant
 
// Récupère les pages gérées par l'utilisateur
sJSON = FBRequest(MaConnexion, sURL)
vJSON = JSONToVariant(sJSON)
The function returns the JSON response of Facebook.
Then, all you have to do is read and access the members documented in the Facebook API: "https://developers.facebook.com/docs/graph-api/reference".
FOR i = 1 _TO_ vJSON.data..Count
ListAdd(LISTE_PAGES, gStoredValue(i) + vJSON.data[i].Name)
END
Minimum version required
  • Version 21
This page is also available for…
Comments
Click [Add] to post a comment