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: 776
  • Facebook_Project_And_Guide.zip
    314.1 KB · Views: 1,161
  • Facebook_Lib_1.9.zip
    29.8 KB · Views: 414
Last edited:

asales

Expert
Licensed User
Longtime User
after called the LogIn method, returns the following error:

"Please verify you have internet Access"

The data connection is active
Where is the problem?

I have the same problem too. My connection is only wi-fi. Android: 2.3.6
 

asales

Expert
Licensed User
Longtime User
Hmmmm, ok, I'll take a look at the library's code, maybe there's an error that's not been captured properly.
Hi NJDude, thanks. In the first tests the samples (Facebook_Project_And_Guide.zip and Facebook_Profile_Sample_2.zip) works fine: login and post in the wall. Now showed this message "connection Error.
 

brelto85

Active Member
Licensed User
Longtime User
Hi NJDude, thanks. In the first tests the samples (Facebook_Project_And_Guide.zip and Facebook_Profile_Sample_2.zip) works fine: login and post in the wall. Now showed this message "connection Error.

same behavior...
probably that a configuration reason of facebook developer?
 

brelto85

Active Member
Licensed User
Longtime User
if the message is generated by your library, do you can say what is the "if statement" that generated it?
probably your library works correctly because after uploadtotimeline, the response event fired and get the idpost but in the dashboard of my Facebook profile the post there isn't

In the Facebook's developer console the app is active, AppDomains, SiteURL and MobileSiteURL are setted
other settings to control?
 

asales

Expert
Licensed User
Longtime User
It is possible, check your configurations, like I mentioned above, I don't have that problem, I even created a new project from scratch and worked fine.
Sorry NJDude, my mistake. I configured the "redirect URIs" with "http://" and put "http://www" in sample. Works now. Thanks.
 

brelto85

Active Member
Licensed User
Longtime User
SOLVED! the problem of message error was generated because the first site was not online. changed it with a online site, it works. sorry!

however remains the problem that after posts a photo and response with IDPOST, the post isn't visible in my facebook's dashboard
there are some permission to do that?
 

NJDude

Expert
Licensed User
Longtime User
If you get an ID it means the post was sent, do you have more than 1 FB account? in order to see the posts on other accounts besides the developer's you have to make your Facebook App PUBLIC, the instructions are in the documentation (html) included with the library.
 

brelto85

Active Member
Licensed User
Longtime User
i've only one facebook's account
the app in developer center is public (image below)

upload_2014-6-23_18-10-18.png


this is app restrictions section

upload_2014-6-23_18-11-22.png

upload_2014-6-23_18-12-33.png
 

NJDude

Expert
Licensed User
Longtime User
I don't know what the problem might be, but it has to be with your settings for example, the only thing I see different with my test app is that the field: SOCIAL DISCOVERY is set to YES.
 
Top