Titanium - Facebook authorize () - "An error occurred"

I use the (Appcelerator) Titanium Facebook API so that users can log in to their facebook accounts. On Android, often immediately after authorization, when you open the facebook window, the page displays:

An error occurred with MY-FB-APP-NAME. Please try later API Error Code: 110 API Error Description: Invalid user id Error Message: Missing user cookie (to validate session user) 

Closing the window and starting work usually solves the problem. However, as it happens, perhaps in 70% of cases (the first time an authorization is called in a "session") this is a big usability problem.

Does anyone know how to fix this?

I am using Titanium 2.1.0 and testing on an Android 2.3.6 device. Thank you very much

+4
source share
2 answers

Actually the problem persists due to facebook cache. we need to clear the cache when you log out using the code below, it works fine

 Titanium.Facebook.appid = "XXXXXXXXXXXXXXXXXX"; Titanium.Facebook.permissions = ['publish_stream', 'read_stream']; var fbButton = Ti.UI.createButton({ top: 68, width:290, height:52, backgroundImage:"images/login/facebook.png" }); fbButton.addEventListener('click', function() { if(Titanium.Facebook.loggedIn){ Titanium.Facebook.logout() return } Titanium.Facebook.authorize(); }); Ti.Facebook.addEventListener('login', function(e) { if (e.success) { win.close() } else if (e.error) { alert(e.error); } else if (e.cancelled) { alert("Canceled"); } }); Titanium.Facebook.addEventListener('logout', function(e) { var url = 'https://login.facebook.com'; var client = Titanium.Network.createHTTPClient(); client.clearCookies(url); }); 
0
source

Try this code, its alloys and hope that it helps you, otherwise I will check and let you know

index.xml

 <Alloy> <Window class="container"> <LoginButton id="fbButton" ns="Alloy.Globals.Facebook"/> </Window> </Alloy> 

index.js

 var fb = Alloy.Globals.Facebook; fb.appid = xxxxxxxxx; fb.permissions = ['publish_stream', 'create_event', 'email']; $.fbButton.style = fb.BUTTON_STYLE_WIDE; fb.addEventListener('login', function(e){ if(e.success){ fb.requestWithGraphPath('me', {}, 'GET', function(e) { if (e.success) { //alert(e.result); var response = JSON.parse(e.result); var email = response.email; var name = response.name; var gender = response.gender; alert(name+' '+email+' '+gender); alert('Logged in Successfully'); } else if (e.error) { alert(e.error); } else { alert('Unknown response'); } }); } }); 

alloy.js

 Alloy.Globals.Facebook = require('facebook'); 
0
source

Source: https://habr.com/ru/post/1436400/


All Articles