[Drupal] [Google API]错误403:执行此操作需要SSL

时间:2015-08-28 08:40:18

标签: ssl drupal-7 google-api

这个错误让我发疯。

我用谷歌搜索,这是由于“https”中缺少“s”但我的代码是正确的,我的端点在网址中有“s”,最重要的是,相同的代码在另一个网站上工作而不是我的。

http://bidicotest.altervista.org/bidico/book/add

这是网站,尝试搜索一本书,错误将显示在上方。

这是我的代码,我100%确定它有效

function get_remote_content($search_term)
{
    $api_end_point = "https://www.googleapis.com/books/v1/volumes?q=";

    $api_param = urlencode($search_term);

    //Chiamata api a google books
    $result = drupal_http_request($api_end_point . $api_param );

    //Se il codice è 200 (ok) o 304 (Not modified)
    if (in_array($result->code, array(200, 304))) {
        return print_book_matching_list($result->data);
    } else { //error
        return "<p>Si è verificato un errore: controllare la connessione.</p>";
    }
}

它给了我:

  

[request] =&gt; GET / books / v1 / volumes?q = asd HTTP / 1.0 User-Agent:Drupal(+ http://drupal.org/)主持人:www.googleapis.com [data] =&gt; {“error”:{“errors”:[{“domain”:“global”,“reason”:“sslRequired”,“message”:“SSL是执行此操作所必需的。”}],“code”:403 ,“message”:“执行此操作需要SSL。”}} [protocol] =&gt; HTTP / 1.0 [status_message] =&gt;禁止[标题] =&gt;数组([cache-control] =&gt; private,max-age = 0 [date] =&gt;星期五,2015年8月28日08:28:11 GMT [accept-ranges] =&gt; none [服务器] =&gt; GSE [vary] =&gt; Origin,Accept-Encoding [content-type] =&gt; application / json; charset = UTF-8 [expires] =&gt; Fri,28 Aug 2015 08:28:11 GMT [x-content- type-options] =&gt; nosniff [x-frame-options] =&gt; SAMEORIGIN [x-xss-protection] =&gt; 1; mode = block)[code] =&gt; 403 [错误] =&gt;禁

我启用了s2s通信,但没有任何改变。

代码完全适用于本地。

我在托管公司的论坛上问过,但没有人知道。 我不能自己解决这个问题,而是在寻求你的帮助。

提前致谢, 斯特凡诺

1 个答案:

答案 0 :(得分:0)

解决。

drupal_http_request使用套接字连接,而不是cURL。

我的托管公司只允许cURL连接。

这就是诀窍: https://www.drupal.org/project/chr