How can I go back from a webpage to an Android app?
<p>I'm trying to create my first Android app in Android Studio that will consume live API data.
To authenticate, I'm following the OAuth 2.0 explanation on <a href="https://developer.foursquare.com/overview/auth" rel="nofollow noreferrer">Foursquare Dev</a>.
First, this lets users login and authorize the app. When authorized, it redirects to a php file on my server on <a href="http://example.com/apps/apptest/index.php" rel="nofollow noreferrer">http://example.com/apps/apptest/index.php</a> containing the following:</p>

<pre><code>&lt;?php

//INIT
header('Content-Type: application/json');
$response = array();

//AUTH
ini_set("allow_url_fopen", 1);

$clientId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$clientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$redirectUrl = urlencode("http://example.com/apps/apptest/index.php");
$code = htmlspecialchars($_GET["code"]);

$url = "https://foursquare.com/oauth2/access_token?client_id=";
$url .= $clientId;
$url .= "&amp;client_secret=";
$url .= $clientSecret;
$url .= "&amp;grant_type=authorization_code&amp;redirect_uri=";
$url .= $redirectUrl;
$url .= "&amp;code=";
$url .= $code;
$json = file_get_contents($url);
$obj = json_decode($json);

$access_token = $obj-&gt;access_token;

$url2 = "https://api.foursquare.com/v2/users/self?oauth_token=" . $access_token . "&amp;v=" . date("Ymd");
$json2 = file_get_contents($url2);
$obj2 = json_decode($json2, true);

$userId = $obj2['response']['user']['id'];

// some mysql things I skipped in this code snippet
if (success) {
   $response["success"] = 1;
   $response["message"] = $access_token;
}
else {
   $response["success"] = 0;
   $response["message"] = "ERROR";
}

echo json_encode($response);

?&gt;
</code></pre>

<p>The problem now is: I can't get back from my web page to my android app!
What I want is the user ID and/or token to be given to the app in some way so that I can consume the foursquare API!
I've been trying all day to get this fixed;
-At first I tried to put an html link in the php file redirecting back to the app, didn't work
-Then I tried "consuming" this self written "API" with Asynchronous tasks in Android, didn't work as well.</p>

<p>Now I ran out of options but I don't want to stop this project, so is there anybody who could tell me what I could try next?</p>

<p>Thanks in advance!</p>