file_get_contents('php://input') hält die Rückkehr leer

Ich versuche zu setup gitkit in meiner website, aber können nicht daran vorbei, auch nur eine einzige Zeile code. Egal was ich mache, file_get_contents hält der Rückkehr leer.

Habe ich bereits meine php.ini : always_populate_raw_post_data = On

Meine Umgebung ist PHP 5.3.3, Apache 2.2.6 localhost.

Hier finden Sie den code.

In meinem index.php rufe ich die google-API, und versuchen Sie den login mit gmail-Konto, in anderen Worten, federated login.

(dies ist aus der Google API Console)

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/googleapis/0.0.4/googleapis.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/jsapi"></script>
<script type="text/javascript">
  google.load("identitytoolkit", "1", {packages: ["ac"], language:"en"});
</script>
<script type="text/javascript">
  $(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();
  });
</script>

Bekomme ich die IDP Antwort, melden Sie sich an und Fragen mich, für die Berechtigungen. Nach der Rückkehr zu meiner callback-Seite, in welche ich den Beispielcode von Google (was unten ist), diese eine Zeile code scheint nicht zu wieder richtig.

Mache ich etwas dumm?

Jede Hilfe wird geschätzt.

Hier die ganze callback.php so weit (es gibt keine HTML auch immer, für jetzt):

  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']) && $_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 => EasyRpService::$SERVER_URL,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
        CURLOPT_POSTFIELDS => json_encode($postData)));
    $response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if ($http_code == '200' && !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

Bevor jemand fragt, ich weiß ersetzen HERE_GOES_MY_DEVELOPER_KEY mit meinem Entwickler-Schlüssel...

Wieder, jede Hilfe wird sehr geschätzt.
C ya.

InformationsquelleAutor Igor Donin | 2012-08-13

Schreibe einen Kommentar