SocialApi SDK Wrappers - B4A Single-Sign-On with multiple providers

Vincenzo Fabiano

Member
Licensed User
Longtime User
Vincenzo,
Not sure if you were asking a question here or offering me help(in which case thanks!). However, if you were asking whether you can use GET for FB integration, the answer is yes as I've just finished doing that.

I am using a combination of WebView and HttpUtils to acquire the access token that you need for posting to FB on a user's behalf. Would be glad to help if you need so :)

All the best.
Haris I would just help! I had not yet read about your problem (which is my own). And I was just looking for a similar solution, can you give me some help? I would be grateful!
 

Vincenzo Fabiano

Member
Licensed User
Longtime User
Vincenzo,

I have added an example project with some description and details of how you can use Facebook's login and do a status post. Here is the link to that example: http://www.b4x.com/android/forum/threads/using-facebook-login-without-social-sdk.44752/

I did not want to keep using this thread for discussion which is essentially about *not* using this SDK! Hope this will be helpful.

Hari Thanks for the tip but I wanted to tell you that I have developed another solution that uses the php-sdk which engages in a complementary way with this library, or rather, the access token recoverable from this magnificent library! The whole advantage of the open graph so .. freedom! Of course, you first need to download the php-sdk and load them on your own domain, then just send the access token with method post or get (MUCH BETTER IN POST) to a page with an ad hoc modified whit common http request, then retrieving the information later printate on the same page. I enclose an example

Sorry for my bad english.
 

Attachments

  • RecuperoPost2.zip
    844 bytes · Views: 285

jhd

Member
Licensed User
Longtime User
Hi, I encoutered an error trying to to Facebook And GooglePlus providers.
For facebook it works but when i try for GooglePlus with Social.GooglePlus.Login(), an error message is display on phone (Internal Error)

Could you help me please ?
 

jhd

Member
Licensed User
Longtime User
I use your api and it works good for facebook but for GooglePlus I have internal error:
Here's the debug:

B4X:
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41c9d428: android.os.BinderProxy@42128820}}
** Activity (main) Pause, UserClosed = false **

Someone have this issue too ?
 

Marcela Calixto

Member
Licensed User
Longtime User
I'm using your Sample1 from multiple. All the logins work fine except for Googleplus. If I use the res that is provided I get
"The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. Google Play services is missing."

I have through the AVD Manager downloaded Google Play Services v20. In the library I have
- android-support-v4.jar
- google-play-services.jar
- GooglePlayServices19.jar

I have made a Client ID for the application using the SHA1


If I update the res to the most recent I get
"java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4452000 but found 6111000. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@Integer/google_play_services_version" />"

I'm using Genymotion as emulator

Anyone can help?
 

Rusty

Well-Known Member
Licensed User
Longtime User
Great code!
Can one retrieve the Facebook User's zipcode, city or address?
Have you created a wrapper for FBGraph?
Thanks,
Rusty
 

ykucuk

Well-Known Member
Licensed User
Longtime User
Twitter provider doesn't work with my galaxy tab4. its look like appear when i click to login button but disappear same time and return to activity. i tried with both samples (twitter and multiple)
any help ?
 

CHAUVET

Member
Licensed User
Longtime User
Waaa is fantastic!
Congratulations, it's a good job!

Do you have an example code for B4J?

Do you think it is possible to use your library with B4J?

thank you,
 

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

facebook bans auotposts. Is there any function for open share dialog for user ?

thanks for help
 

henrywood

Active Member
Licensed User
Longtime User
I cannot compile my project when using SocialAPI ???

I get an OutOfMemory exception:


B4A version 4.30
Parsing code. 0.47
Compiling code. 2.72
Compiling layouts code. 0.76
Generating R file. 1.19
Compiling debugger engine code. 13.95
Compiling generated Java code. 14.20
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.rop.code.Rops.opMoveResult(Rops.java:1298)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:487)
at com.android.dx.cf.code.Simulator$SimVisitor.visitConstant(Simulator.java:691)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:764)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:782)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:737)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:346)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:682)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:170)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
Optimized dexer failed. Switching to Standard dexer.


Any ideas what can be causing this or how I free up some memory - this is a 8GB machine, running only B4A and 8 Firefox windows...
I am using all of the providers
 

henrywood

Active Member
Licensed User
Longtime User
I am trying out the SocialAPI and it appears to be a cool library, but I have some problems.

1. I tried logging in with my facebook account which worked in the "multiple/sample1" sample
However, the email field was empty and I need this field (ie. Provider.User.Email was NULL ?) - How do I request that Email should be filled out (via permissions ?) I am trying to use all of the 4 providers in my app, and get the email + name regardless of the provider used to connect ?
2. I then tried logging in when my GMAIL/GOOGLE credentials but that did not work... Most of the time nothing happened when I clicked that I want to connect via Google+. At other times the OAUTH Permissions dialog from Google appeared but then nothing happened when I clicked OK/Allow ?
3. Below I am trying to write an activity to signup using the 4 providers. What is the purpose of/need for Provider_Event in this context ?

Can anyone shine a light ?

Please note that I know only a little about Facebook as I am in fact not using it for myself.

Thanks


/Henrik


B4X:
Sub Activity_Resume
   ThisActivity.InitializeAndBind(Social.Providers, "provider")
End Sub

Sub Provider_Event (Provider As SocialApiProvider)
  'Since this event will be raised by all providers, we don't want to process events
  'from other providers if we are already connected
  If Social.ActiveProvider <> Null AND Social.ActiveProvider <> Provider Then Return
   
End Sub

Sub Provider_Connected (Provider As SocialApiProvider)

   Dim u As User

   Dim userEmail As String = Provider.User.Email
   Dim nick As String = Provider.User.Name
   Dim fullName As String
   Dim gender As String
   Dim birth As Long
   Dim userAge As Int
   Dim tmp As String
   Dim p As Period
   Dim minAge As Int
   Dim maxAge As Int
   Dim ageMap As Map
   
   If Provider Is FacebookProvider Then
   
     Dim fb As FacebookProvider
     Dim Temp As FacebookResult
   
     Temp = fb.GetMe(Array As String(fb.Constants.UserFields.FIRST_NAME, fb.Constants.UserFields.LAST_NAME, _
                     fb.Constants.UserFields.gender, fb.Constants.UserFields.BIRTHDAY, _
                     fb.Constants.UserFields.AGE_RANGE))
     Dim data As Map = Temp.Map
     fullName = data.Get(fb.Constants.UserFields.FIRST_NAME) & " " & data.Get(fb.Constants.UserFields.LAST_NAME)
     gender = data.Get(fb.Constants.UserFields.gender)
     gender = gender.ToLowerCase.SubString2(0, 1)
     tmp = data.Get(fb.Constants.UserFields.BIRTHDAY)

     If tmp <> Null Then
       birth = DateTime.DateParse(tmp)
       userAge = DateUtils.PeriodBetween(birth, DateTime.Now).Years
     Else
     
       If data.ContainsKey(fb.Constants.UserFields.AGE_RANGE) Then
       
           ageMap = data.Get(fb.Constants.UserFields.AGE_RANGE)
           
           If ageMap.ContainsKey("min") AND ageMap.ContainsKey("max") Then
             
               If ageMap.Get("max") <> "" Then
                 userAge = ((minAge + maxAge) / 2)
               Else
                 userAge = minAge
               End If
               
           Else
             ' No age info
           
           End If
       End If
       
     End If
     
     ' Request publishing perms
     fb.RequestPublishPermissions
   
   End If
   
   If Provider Is TwitterProvider Then
   
     Dim t As TwitterProvider
     Dim Temp As FacebookResult
   
     Temp = t.GetMe
     Dim data As Map = Temp.Map

     
     
   End If
   
   
   
   ' Build our own user object here
   
   
   
   
   
   
End Sub

Sub Provider_Disconnected (Provider As SocialApiProvider)



End Sub

Sub Provider_Failed (Provider As SocialApiProvider)
   
   If Msgbox2("Provider '" & Provider.Type & "' failed to actualize your details."&CRLF&CRLF&"Retry?", Provider.Type & ": Error", "Yes", "No", "", Null) = DialogResponse.POSITIVE Then
  Provider.Retry
  End If

End Sub
 

bluedude

Well-Known Member
Licensed User
Longtime User
I have issue retreiving the email address even when adding codeSocialLogin.Facebook.Constants.Permissions.Email

Any suggestions?
 

luke2012

Well-Known Member
Licensed User
Longtime User
It's possibile to use this wrapper to get user's eMail credentials to send an eMail within the app code ?
 
Top