简体   繁体   English

Google 不喜欢我的 WAMP 服务器。 谁有想法?

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

Alright I'm at the end of the rope here.好吧,我已经到了穷途末路了。 I've tried just about everything to try to get this working.我已经尝试了几乎所有方法来使它正常工作。 I've done Google OAUTH API calls before on web hosts and everything works great, but when I use the same scripts on my WAMP server, google does not reply to my cURL posts.我之前在 web 主机上完成了 Google OAUTH API 调用,一切正常,但是当我在我的 WAMP 服务器上使用相同的脚本时,谷歌不会回复我的 cURL 帖子。 I've tested cURL post by posting to my own server as well as to this server someone set up:我已经测试了 cURL 帖子,方法是发布到我自己的服务器以及有人设置的这个服务器:

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

And it works just fine.它工作得很好。 Here's the script I'm using after I get the user to allow my application:这是我在让用户允许我的应用程序后使用的脚本:

<?

//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/");  
}

?>

When I echo out what is supposed to be the google response, all I get is a singular "/".当我回显应该是谷歌响应的内容时,我得到的只是一个单数“/”。 When I run this same exact script on my webhost, after changing back the DNS IP, it works fine.当我在我的虚拟主机上运行完全相同的脚本时,在改回 DNS IP 后,它工作正常。 I'm thinking either Google doesn't like my WAMP server and won't even talk to it, or perhaps it's something with my cURL configuration.我在想,要么是 Google 不喜欢我的 WAMP 服务器,甚至不愿与其交谈,要么是我的 cURL 配置有问题。 It's only a minor annoyance not being able to develop for Google API on my WAMP server, but if anyone has any ideas whatsoever, it would be greatly appreciated.无法在我的 WAMP 服务器上为 Google API 开发只是一个小烦恼,但如果有人有任何想法,我们将不胜感激。

Thanks!谢谢!

I was getting a FALSE coming back from curl_exec() , but this is how I fixed it:我从curl_exec()返回一个FALSE ,但这就是我修复它的方式:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

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

hope this helps!希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的SQL代码似乎没有连接到我的服务器。 它曾经做到过,并且可以在我的Wamp服务器上使用 - My SQL code doesn't seem to be connecting to my server. It used to do it and it works on my Wamp server WAMP服务器错误“禁止访问您无权访问此服务器上的/ phpmyadmin /。” - WAMP Server ERROR “Forbidden You don't have permission to access /phpmyadmin/ on this server.” WAMP“您无权访问此服务器上的/ Health_1st /&gt;。” - WAMP “You don't have permission to access /Health_1st/> on this server.” 如何在64位WAMP 3上修复“您无权访问此服务器上的/index.php。” - How to fix “You don't have permission to access /index.php on this server.” on 64bit WAMP 3 Wamp服务器未显示我的本地网站 - Wamp server doesn't show my local website 有人对这个zip脚本有想法吗? - Anyone have ideas for this zip script? 我的服务器上没有 cron 作业。 在没有用户输入的情况下发送电子邮件的替代方法是什么? - I don't have cron jobs on my server. What is an alternative for sending emails without user input? PHP无法在我的Nginx + php5-fpm服务器上执行。 空白页 - PHP doesn't execute in on my Nginx + php5-fpm server. Blank page 为什么我的表单不能在一台服务器上工作。 但另一方面呢? - Why doesn't my form work on one server. but does on the other? 网站的功能与我的localhost(沼泽)服务器上的功能不同 - Website doesn't function the same way as it does on my localhost (wamp) server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM