简体   繁体   中英

How to read data via a URL with PHP

I am trying to make my online app communicate with Facebook. According to their documentation in order to authenticate my users I need to redirect them to the oAuth dialog, with this URL:

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL

So far so good. If the user grants me permission Facebook will redirect him to the URL I specified on my request, appending a code to it. Like this:

http://YOUR_URL?code=A_CODE_GENERATED_BY_SERVER

Question : how do I read that code with my PHP script?

使用$_GET

echo $_GET['code'];

So the response URL should be like http://youdomain.com/controller.php?code=A_CODE_GENERATED_BY_SERVER

in your controller.php

$_REQUEST['code']

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