简体   繁体   English

如何使用PHP通过URL读取数据

[英]How to read data via a URL with PHP

I am trying to make my online app communicate with Facebook. 我正在尝试使我的在线应用程序与Facebook交流。 According to their documentation in order to authenticate my users I need to redirect them to the oAuth dialog, with this URL: 根据他们的文档,为了验证我的用户,我需要使用以下URL将它们重定向到oAuth对话框:

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. 如果用户授予我权限,Facebook会将其重定向到我在请求中指定的URL,并向其添加代码。 Like this: 像这样:

http://YOUR_URL?code=A_CODE_GENERATED_BY_SERVER

Question : how do I read that code with my PHP script? 问题 :如何使用PHP脚本读取该代码?

使用$_GET

echo $_GET['code'];

So the response URL should be like http://youdomain.com/controller.php?code=A_CODE_GENERATED_BY_SERVER 因此,响应网址应类似于http://youdomain.com/controller.php?code=A_CODE_GENERATED_BY_SERVER

in your controller.php 在你的controller.php中

$_REQUEST['code']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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