Facebook Test User API login url working or not ra

2019-08-12 06:49发布

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条回答
手持菜刀,她持情操
2楼-- · 2019-08-12 07:45

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)

查看更多
登录 后发表回答