Daniel Scocco
Daniel Scocco

Reputation: 7266

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?

Upvotes: 1

Views: 191

Answers (2)

Churk
Churk

Reputation: 4627

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

in your controller.php

$_REQUEST['code']

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382656

With $_GET:

echo $_GET['code'];

Upvotes: 2

Related Questions