Facebook Test User API login url working or not randomly

风流意气都作罢 提交于 2019-12-11 09:52:48

问题


I have wrote a desktop app, that holds FB applications data and lists test users. I want to open a browser with new profile (browser profile, not FB, because to session problems in PHP facebook API - I want to be not in my a app session on my domain).

But the problem is, that facebook login URL is working or not randomly. I have tried Firefox & Chrome.

Firefox with -no-remote, -p "RANDOM_PROFILE", and also -CreateProfile executing before execution to open url with that profile.

Chrome with --profile-directory="RANDOM_DIR" (directory created earlier).

Managing browser profiles works good in both browser. But in most cases, opening browser with Facebook Test User login URL, just redirects me to main page.

Also, i have created a some PHP pages:

  • one redirecting after a while to login URL by window.location
  • one redirecting after a sleep by header('Location: ...') to login url
  • one with <a href...> tag to login url.

Third option is the only one working, but it works in about 20% cases (sometimes clicking many times on that link & opening multiple times in new tabs is working)

How to do launch of a new browser instance with facebook login URL where loging works fine ?

Edit: my loging URL's are always fetched from FB very shortly before login try, so they aren't expired.


回答1:


I finally got this.

The problem is, that http://facebook.com must be loaded at least one time (propably for setting some cookies) before using Test User login URL.

So, i use a script to open the Facebook in iframe, and then after some time redirects to login url:

<script>
setTimeout(function(){
window.location = "<?php echo $_GET['url']; ?>";
} , 2000 );
</script>
<iframe src="http://facebook.com/"></iframe>

Notice that facebook on iframe will load as head+body only blank page, but this is working.

Then you can use this script to login Test User by passing it to Chrome command line, with url-encoded Test-User-Login-URL as 'url' GET parameter.

Use fresh created directory for chrome profile to avoid getting old session on your app domain.

Also, I suggest using arguments: --start-maximized, --no-default-browser-check, --no-first-run

UPDATE: Notice that requested login URL will work only once with this method (and maybe any other methods - didn't checked)



来源:https://stackoverflow.com/questions/11574514/facebook-test-user-api-login-url-working-or-not-randomly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!