Note that there are some explanatory texts on larger screens.

plurals
  1. POfile_get_contents('php://input') keeps returning empty
    primarykey
    data
    text
    <p>I'm trying to setup gitkit in my website, but can't get past this one single line of code. No matter what I do, <code>file_get_contents</code> keeps returning empty.</p> <p>I've already set my php.ini : <code>always_populate_raw_post_data = On</code></p> <p>My environment is <code>PHP 5.3.3</code>, <code>Apache 2.2.6</code>, localhost.</p> <p>Here's some code.</p> <p>In my index.php, I call the google API and try to login with gmail account, in other words, federated login.</p> <p>(this is from the Google API Console)</p> <pre><code>&lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/googleapis/0.0.4/googleapis.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="//ajax.googleapis.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; google.load("identitytoolkit", "1", {packages: ["ac"], language:"en"}); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { window.google.identitytoolkit.setConfig({ developerKey: "HERE_GOES_MY_DEVELOPER_KEY", companyName: "Valentinos Pizzaria", callbackUrl: "http://localhost/valentinos/callback.php", realm: "", userStatusUrl: "http://localhost/valentinos/userstatus.php", loginUrl: "http://localhost/valentinos/login.php", signupUrl: "http://localhost/valentinos/register.php", homeUrl: "http://localhost/valentinos/index.php", logoutUrl: "http://localhost/valentinos/logout.php", idps: ["Gmail", "Yahoo"], tryFederatedFirst: true, useCachedUserStatus: false, useContextParam: true }); $("#navbar").accountChooser(); }); &lt;/script&gt; </code></pre> <p>I get the IDP response, log in, and am asked for permissions. Upon returning to my callback page, in which I used the code sample provided by Google (which is below), this one line of code doesn't seem to be returning correctly.</p> <p>Am I doing anything stupid at all?</p> <p>Any help will be appreciated.</p> <p>Here's whole callback.php so far (there's no HTML whatsoever, for now):</p> <pre><code> session_start(); $url = EasyRpService::getCurrentUrl(); #$postData = @file_get_contents('php://input'); $postData = file_get_contents('php://input'); $result = EasyRpService::verify($url, $postData); // Turn on for debugging. // var_dump($result); class EasyRpService { // Replace $YOUR_DEVELOPER_KEY private static $SERVER_URL = 'https://www.googleapis.com/rpc?key=HERE_GOES_MY_DEVELOPER_KEY'; public static function getCurrentUrl() { $url = (isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; $url .= $_SERVER['SERVER_NAME']; if ($_SERVER['SERVER_PORT'] != '80') { $url .= ':'. $_SERVER['SERVER_PORT']; } $url .= $_SERVER['REQUEST_URI']; return $url; } private static function post($postData) { $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL =&gt; EasyRpService::$SERVER_URL, CURLOPT_RETURNTRANSFER =&gt; 1, CURLOPT_HTTPHEADER =&gt; array('Content-Type: application/json'), CURLOPT_POSTFIELDS =&gt; json_encode($postData))); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code == '200' &amp;&amp; !empty($response)) { return json_decode($response, true); } return NULL; } public static function verify($continueUri, $response) { $request = array(); $request['method'] = 'identitytoolkit.relyingparty.verifyAssertion'; $request['apiVersion'] = 'v1'; $request['params'] = array(); $request['params']['requestUri'] = $continueUri; $request['params']['postBody'] = $response; $result = EasyRpService::post($request); if (!empty($result['result'])) { return $result['result']; } return NULL; } } # End Class EasyRpService </code></pre> <p>Before anyone asks, I do replace <code>HERE_GOES_MY_DEVELOPER_KEY</code> with my Developer Key...</p> <p>Once again, any help will be much appreciated. C ya.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload