Facebook SDK Wrapper + Native Facebook LoginButton

Douglas Farias

Expert
Licensed User
Longtime User
this works

B4X:
        Dim Result As FacebookResult = Main.FB.PublishPost("Confira o aplicativo que distribui dinheiro pela cidade. Lançamento em BREVE!!!","http://www.vallow.com.br/achouganhou/", "http://www.vallow.com.br/achouganhou/compartilhar.jpg" ,"Achou Ganhou", Null, "O aplicativo que distribui dinheiro pela cidade confira!")
        If Result.Success = True Then
        updatecompartilhou
        Else
        Msgbox("Não foi possível compartilhar! tente novamente","Achou Ganhou")
        End If
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Update: 1.3

Updated files: facebook.zip

  • Now, there is 1 zip file that contains all samples and the wrapper.
  • There is no need now to manually call Facebook.Me, since the logged-in user's details will be fetched automatically whenever the system gets an access token
  • The previously Facebook.Me Method is now a Map object, and there is a new Facebook.GetMe method instead
  • There is a new Facebook.JustLoggedIn property that will be set once when connected and will ensure that Facebook.Me has all logged in user details.
  • All samples updated.
  • Various bug fixes
Important: The Facebook Object MUST be declared in Sub Process_Globals

How to use FB.JustConnected and Facebook.Me:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    Public FB As Facebook
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim CurrentActivity As FacebookActivity
End Sub

Sub Activity_Resume
    FB.SetActivity(CurrentActivity.Initialize("facebook_statuschanged_event"))
End Sub

Sub facebook_statuschanged_event
    'Access FB public properties and update UI accordingly when session changes

    If FB.JustConnected Then 'JustConnected property will be set to true only when connected once
        Msgbox(FB.Me, "JustConnected!") 'FB.Me is a Map object that contains all user details
    End If
End Sub
 
Last edited:

brelto85

Active Member
Licensed User
Longtime User
Is possibile to call the UploadPhoto method when the Facebook object is declared in a common module?
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Only Facebook.Login and permission related functions must be called from an activity module. All other calls can safely be made from anywhere else.

Just ensure that you have only 1 Facebook object declared in a Sub Process_Global

Check Sample1 which utilizes a common module and 2 activities sharing the same process global Facebook object.
 
Last edited:

brelto85

Active Member
Licensed User
Longtime User
ok thanks!
why after uploaded a photo, this goes into an album and must be approved?
is possibile from default prevent this behavior?
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
This is by facebook design and occurs if you haven't previously requested publish permissions.

Do a Facebook.RequestPublishPermissions first and then call Facebook.UploadPhoto or Facebook.UploadVideo.

Also, Facebook.UploadPhoto currently does not take an AlbumId as a parameter resulting in uploading to an app specific album (called "<appname>'s Photos"). Next wrapper update will introduce managing albums and photos functionality as well as specifying an AlbumId when using Facebook.UploadPhoto.
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Update: 1.4

Updated files: facebook.zip

  • Removed: generic method Facebook.Request
  • Added: generic methods Facebook.Get, Facebook.Post, Facebook.Delete
  • Added: Facebook.CreateAlbum, Facebook.GetAlbums, Facebook.GetAlbum, Facebook.GetPhotos, Facebook.DeletePhoto
  • Added: extra parameter AlbumId (returned by Facebook.CreateAlbum and Facebook.GetAlbum) to Facebook.UploadPhoto. Set it to "" to upload to the app's default album
  • Samples updated.
 
Last edited:

brelto85

Active Member
Licensed User
Longtime User
a question:
Why in the facebook's basic settings page, "App Domains", "Site URL" and "Mobile Site URL" are required?
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
It is only required if you have added a website platform.

You can remove all platforms and leave only the android platform. The Appdomains field is not required in that case.


upload_2014-6-27_12-16-42.png
 

brelto85

Active Member
Licensed User
Longtime User
ok, thanks
another question

what is the difference between the two facebook login popup that i've attached?
 

Attachments

  • 851581_330219157107655_1453716895_n.png
    851581_330219157107655_1453716895_n.png
    196.8 KB · Views: 195
  • 10173504_747059372004917_1281001803_n.png
    10173504_747059372004917_1281001803_n.png
    92 KB · Views: 190

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
The first one will appear on devices that have the facebook app installed and are live.
The second one on devices without the facebook app.
 

Douglas Farias

Expert
Licensed User
Longtime User
The first one will appear on devices that have the facebook app installed and are live.
The second one on devices without the facebook app.
strange because

on my moto g i have the facebook and show me the second android 4.3.3

on my s3 and my tablet i have facebook show me the first
 

brelto85

Active Member
Licensed User
Longtime User
strange because

on my moto g i have the facebook and show me the second android 4.3.3

on my s3 and my tablet i have facebook show me the first

same behavior
i've the Facebook app but appears the second (white page full screen)

it just to know if at base of these there's a different logic to login
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Update: 1.5

Updated files: facebook.zip

  • Added: Facebook.GetPhoto
  • All "please-wait" dialogs are now cancelable. If user cancels, Facebook.Result.Canceled will be true
  • Added: upload progress while uploading
  • Samples updated.
Note: When uploading files from Assets there will be only an indeterminate progress bar with bytes uploaded shown, since there is no way to get the size of a file in assets (they are compressed resources)

upload_2014-6-27_15-44-47.png
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
@brelto85 No worries. What is shown and when is handled internally by the facebook SDK and the installed facebook app. The end-user logic is always the same. You don't have to change the login logic in your code.
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Update: 1.51

Updated files: facebook.zip [wrapper: YES samples: NO]

  • Enhancement: Better upload progress representation

upload_2014-6-27_18-19-5.png
 
Last edited:
Top