简体   繁体   中英

get a # from a url in php

I'm trying to code with the facebook API

here it says : http://developers.facebook.com/docs/authentication/javascript to get the access_token thing, but it's after a # and not a ?

so how can I get it ?

http://www.example.com/callback#access_token=...&expires_in= ...

You won't be able to do it in PHP - you can only access it in javascript - the fragment/hash never reaches the server, it is processed by the browser

in Javascript, you can access the fragment using

window.location.hash

The fragment identifier is only used client side. The browser doesn't send it to the server, so you can't access it with PHP.

To quote the page you link to:

Your JavaScript library can read the token from the URL and store it in a cookie for future use.

You have to use JS to read it before it can be sent to the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM