谷歌没有;我不喜欢我的WAMP服务器.任何人都有任何想法


Google doesn't like my WAMP server. Anyone have any ideas?

好吧,我已经到了极限。我已经尽了一切努力来让它发挥作用。我以前在网络主机上做过Google OAUTH API调用,一切都很好,但当我在WAMP服务器上使用相同的脚本时,Google不会回复我的cURL帖子。我已经通过发布到我自己的服务器以及某人设置的这个服务器来测试cURL帖子:

http://www.newburghschools.org/testfolder/dump.php

而且效果很好。这是我让用户允许我的应用程序后使用的脚本:

<?
//This script handles the response from google. If the user as authed the app, it will continue the process by formulating another URL request to Google to get the users information. If there was an error, it will simply redirect to index.
include_once($_SERVER['DOCUMENT_ROOT']."/../src/php/google/initialize.php");
if (!isset($_GET['error'])) {
    //No error found, formulate next HTTP post request to get our auth token
    //Set URL and get our data encoded for POST
    $url = "https://accounts.google.com/o/oauth2/token";
    $fields = array(
        'code' => $_GET['code'],
        'client_id' => $google['clientID'],
        'client_secret' => $google['clientSecret'],
        'redirect_uri' => "http://www.dealertec.com/scripts/php/google/reg_response.php",
        'grant_type' => "authorization_code"
    );
    //$data = http_build_query($fields);
    $data = "code=".$fields['code'].'&client_id='.$fields['client_id'].'&client_secret='.$fields['client_secret'].'&redirect_uri='.$fields['redirect_uri'].'&grant_type='.$fields['grant_type'];
    echo $data."<br> /";
    //Begin cURL function
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    echo $response;
    curl_close($ch);
    //Decode the JSON and use it to make a request for user information
    print_r($response);
    $response = json_decode($response, true);
    /*if (!isset($response['error'])) {
        //No error in response, procede with final step of acquiring users information
        $apiURL = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=".$response['access_token'];
        $apiCall = curl_init($apiURL);  
        curl_setopt($apiCall, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($apiCall, CURLOPT_HEADER, false);
        $apiResponse = curl_exec($apiCall);
        $apiResponse = json_decode($apiResponse, true);
        var_dump($apiResponse);
    }else{
        echo $response['error'];    
    }*/
}else{
    header("LOCATION: http://www.dealertec.com/");  
}
?>

当我回应谷歌的回应时,我得到的只是一个单数"/"。当我在我的网络主机上运行同样的脚本时,在更改回DNS IP后,它运行得很好。我在想,要么谷歌不喜欢我的WAMP服务器,甚至不会和它说话,要么可能是因为我的cURL配置。不能在我的WAMP服务器上为Google API开发只是一个小小的烦恼,但如果有人有任何想法,我将不胜感激。

谢谢!

我从curl_exec()收到了一个FALSE,但我就是这样修复的:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

http://us3.php.net/manual/en/function.curl-setopt.php

希望这能有所帮助!