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

brelto85

Active Member
Licensed User
Longtime User
ok, but i've a question.
The ActiveProvider in Social module, returns the provider that is connected
If in my preference activity i've connected two social (Facebook and twitter), it returns always the first
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
In your case, you should not use the Social.ActiveProvider at all since you can have more than 1 providers connected. Just address each Provider individually.
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
If you want to have a single share you can do this:

B4X:
Sub Share(Message as String, PathName As String, FileName As String)
    If Social.Facebook.Connected Then
        Social.Facebook.UploadPhoto(PathName, FileName, Message, "")
    End If
    If Social.Twitter.Connected Then
        Social.Twitter.TweetMedia(Message, PathName, FileName)
    End If
End Sub
 

brelto85

Active Member
Licensed User
Longtime User
ok, i changed it deleting the ActiveProvider reference but i don't understand why does not call the Provider_JustDisconnect method after Logout method
in addition, the provider_event fired for all providers declared (in my case two times for FAcebook and Twitter) after have clicked the checkbox Facebook Login (view my code)
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
It is normal to be fired for all providers. It is a measure to enforce a global UI update since the activity gets paused and resumed after a facebook logout.

Have you tested the sample2 APK? Have you checked the source in sample2.zip?
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
upload_2014-7-8_1-21-30.png
upload_2014-7-8_1-21-46.png
 

Douglas Farias

Expert
Licensed User
Longtime User
how can i get the city on google api?
on Common.GooglePlus.Me
i dont see city =(
 

brelto85

Active Member
Licensed User
Longtime User
yes, with your sample works all

1. For the problem disconnect Facebook i don't know where is the cause. The code is the same
2. For the twitter the cause are my api keys. I've changed your keys with mine in sample2 and i have the same behaviors. After click Login, show the wait dialog and after that not appears anything. Probably is some settings in the developer console
 

brelto85

Active Member
Licensed User
Longtime User
i've notice the strange behavior
I've this scenario:
In main activity_resume event call the BindWithEvent method
After disconnect FacebookProvider into PreferenceActivity (that i've also here call the bindwithevent) open the main activiy and gets the "provider_justdisconnectd was not found" error
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User

walterf25

Expert
Licensed User
Longtime User

brelto85

Active Member
Licensed User
Longtime User
Is there a spelling error in the code ?

provider_justdisconnectd

No sorry, i wrote wrong here. "....provider_justdisconnect was not found". the problem is that opened the Main activity as if the sender object was Main activity

Can you please make a screenshot the app when the twitter login hangs? Just that screen

I've attached the screen. After that "Loading..." dialog, nothing appears
 

Attachments

  • 2014-07-08_09-16-18.png
    2014-07-08_09-16-18.png
    57.7 KB · Views: 188

geola

Member
Licensed User
Longtime User
yes, with your sample works all

1. For the problem disconnect Facebook i don't know where is the cause. The code is the same
2. For the twitter the cause are my api keys. I've changed your keys with mine in sample2 and i have the same behaviors. After click Login, show the wait dialog and after that not appears anything. Probably is some settings in the developer console

I had the same problem. You have to define a Callback URL in the Twitter application console. Than it works.

Michael
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Update: 2.4

Most of the changes have overall minimized the code needed and made the application logic more b4a compliant.
  • [SocialApi] Added: BaseResult
  • [SocialApi] Changed: All provider results are now derived from BaseResult
  • [SocialApiProvider] Renamed: GetWithEvent to Initialize and BindWithEvent to InitializeAndBind
  • [SocialApiProvider] Removed: JustConnected, JustDisconnected, Failed properties
  • [SocialApiProvider] Added: Provider_Connected,Provider_Disconnected, Provider_Failed events and Ready property
  • [SocialApiProvider] Added: Upload method
  • [GooglePlusProvider] Changed: All calls return GoogleResult instead of Map which is derived from BaseResult
  • Added sample2 in socialapi\multiple\samples
  • Updated all samples with the new events
 
Last edited:

brelto85

Active Member
Licensed User
Longtime User
Thanks!! now works perfectly also the twitter login page is shown after update the twitter settings with Callback URL
but after inserted my credentials, appears also the facebook login without prompt any errors. my callback url is a real site ("http://altervista_site/") without specified the index page
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Tip: You can use any site as a callback in twitter since it is completely ignored in code.
 
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
@Periklis Koutsogiannis
hi man
i have a question
i m making login with google and facebook
i have a common with facebook and google declared

on my main i call

B4X:
Sub Activity_Resume

        Common.Facebook.SetActivity(ThisActivityface.Initialize("facebook"))
        Common.GooglePlus.SetActivity(ThisActivitygoogle.Initialize("googleplus"))
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub imgface_Click
        Common.Facebook.Login(Array As String (Common.Facebook.Constants.Permissions.Email))
End Sub

Sub imggoogle_Click
        Common.GooglePlus.Login
End Sub


ok

later i have this
B4X:
Sub Facebook_Connected (Provider As SocialApiProvider)
    If Not(Common.Facebook.HasPermission(Common.Facebook.Constants.Permissions.PUBLISH_ACTIONS)) Then
        Common.Facebook.RequestPublishPermissions
    End If
    idsocial = Provider.Me.Get("id")
    confereusuario
End Sub

Sub Facebook_Disconnected (Provider As SocialApiProvider)
  'here
End Sub


if user conected on facebook make this query
confereusuario


and this works fine ok

but when i go make a log out


B4X:
Sub Button1_Click
    Common.Facebook.Logout
End Sub


when i click at Button1_Click to logout
execute this query again
confereusuario

why ? *-*

note my facebook disconect is empity

Sub Facebook_Disconnected (Provider As SocialApiProvider)
'here
End Sub


with google i dont have this problem only face
 
Top