B4A Library Facebook

This library will allow your apps to interact with Facebook.


Requirements:

1- B4A 3.x

2- Facebook account.

3- Copy the Facebook.xml and Facebook.jar to your additional libraries directory.


Usage:
B4X:
'Initialize the library
Dim FB As Facebook

'Get the following 3 fields from Facebook after creating a Facebook app.
Dim AppID As String = "<APP_ID_FROM_FACEBOOK>"
Dim AppSecret As String = "<APP_SECRET_FROM_FACEBOOK>"
Dim myWebsite As String = "<LINK_TO_THE_WEBSITE_IN_REDIRECT_URI>"

FB.Initialize(Activity, Me, "myFB", AppID, AppSecret, myWebsite)

'Login to Facebook
FB.Login

'Get your profile
FB.GetMyProfile

...

'Display profile fields
Sub myFB_MyProfile_Response(Profile As Map)

    Dim Temp As String

    For I = 0 To Profile.Size - 1

        Temp = Temp & Profile.GetKeyAt(I) & ": " & Profile.GetValueAt(I) & CRLF

    Next

    Msgbox(Temp, "My Profile")


End Sub

The attached files contain:

a- The Facebook library.

b- "How to create a Facebook app" quick guide.

c- A sample project.


NOTES: You have to have some basic knowledge of the Facebook API to use it, especially about permissions, the library allows you to interact with Facebook but you are responsible to add/remove the necessary permissions for the actions you want to perform.

You have to create a Facebook app before you can use the library, the instructions are in the quick guide mentioned on item "b" above.


A DEMO app (apk) is also attached for you to take a look at the library's functionality.

Library recompiled on May 28, 2017 (B4A 6.8+)
 

Attachments

  • FacebookDemoApp.apk
    231.9 KB · Views: 708
  • Facebook_Project_And_Guide.zip
    314.1 KB · Views: 1,072
  • Facebook_Lib_1.9.zip
    29.8 KB · Views: 345
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
i seted http://likeapps.net/index.html and works but i need clean the cache of app to work

have a way to make a button the cleand this app cache? can make a log out with this

now works fine i cleaned the cache and works *-*
 

Douglas Farias

Expert
Licensed User
Longtime User
NJDUDE how can i return the profile result in edittext1.text?

i m trying

Sub GetMyProfileButton_Click

fb.GetMyProfile

EditText1.TEXT = fb.USER_FIELD_NAME
End Sub

but it return name only

how the simple way to show the result Douglas name?
 

Douglas Farias

Expert
Licensed User
Longtime User
ok this works
edittext1.Text = profile.Get("locale")
last question this show the strings only
but the profile photo?

imageview.bitmap = ?
 

tuhatinhvn

Active Member
Licensed User
Longtime User
why give me error
redirect_uri isn't an absolute URI check RDC 3986

i m tryed to use localhost
http://google.com

my site www.likeapps.net and http://likeapps.net

and same error *-*
same with login

{
"error": {
"message": "redirect_uri isn't an absoluted URI. Check RFC 3986.",
"type": "OAuthException",
"code": 191
}
}



when i try another button show me

Facebook Error
Cannot post message to the timeline

an active acess token must be used to query information about the current user.

Close


here is the image

how do you fix it?
 

Douglas Farias

Expert
Licensed User
Longtime User
need a page exemple google.com/index.html < index.html

and need clean app cache later, only unistal and install the app again dont solv the problem need clean the app cache *-*
 

Douglas Farias

Expert
Licensed User
Longtime User
yes can you get all informations and show this on your app
name
gender etc

photo is only the problem u need open the webview with the url


B4X:
                    resultado =  Profile.Get("id")
                   
                    'ImageView1.Bitmap = caca
                   
                    caca2 = "https://graph.facebook.com/" & resultado & "/picture"

i dont know the code to get profile photo *-*
 

walterf25

Expert
Licensed User
Longtime User
About time you released it Bud, hahaha!
Great Job, i must say i'm the first one to use your library in my whack A Bieber game.

Thanks a lot bud, and great Job!!!!
 

Douglas Farias

Expert
Licensed User
Longtime User
very thx NJDude you help many many users *-*
 

Douglas Farias

Expert
Licensed User
Longtime User
NJDude its prosible to remove the close icon in the facebook login to force player log on ? or get a result when player close the login page?

exemple i click at login button and i close this on x icon show me a msgbox login closed
 

Douglas Farias

Expert
Licensed User
Longtime User
but have a way to get a result when he close ?
 

sonicmayne

Member
Licensed User
Longtime User
I get the error "An active access token must be used to query information about the current user" when trying to use the sample app.
 
Top