致命错误:未捕获CurlException:7:无法连接到第887行的src / base_facebook.php中抛出的主机 [英] Fatal error: Uncaught CurlException: 7: couldn't connect to host thrown in ....src/base_facebook.php on line 887

查看:266
本文介绍了致命错误:未捕获CurlException:7:无法连接到第887行的src / base_facebook.php中抛出的主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个示例facebook php登录示例,例子如下:



,然后尝试添加任何Facebook呼叫

  facebook :: $ CURL_OPTS [CURLOPT_CAINFO] ='path / to / fb_ca_chain_bundle.crt'; 

您还可以尝试

  facebook :: $ CURL_OPTS [CURLOPT_SSL_VERIFYPEER] = false; 
facebook :: $ CURL_OPTS [CURLOPT_SSL_VERIFYHOST] = 2;


I'm trying to develop a sample facebook php login example following the example here

I've hosted my app here, but I'm getting the error message in the question whenever I try to access the link. Here's the code segment that throws the error

try {
  $e = new FacebookApiException(array(// LINE 887
             'error_code' => curl_errno($ch),
             'error' => array(
             'message' => curl_error($ch),
             'type' => 'CurlException',
        ),
  ));
  curl_close($ch);
}

// edit suggested by Kneel-before ZOD
catch(FacebookApiException $e) {
  $result = $e->getResult();
  echo 'Got an : ', $e->getType(),' while posting';
  echo(json_encode($result));
}

catch(Exception $e){
  echo 'Caught exception: ',  $e->getMessage(), "\n";
}

Im quite sure Ive setup the APP ID and secret correctly in index.php.

Here's a screenshot of my app setup on facebook

Any help would be appreciated. Thanks!

解决方案

You may need to give curl a certificate file for Facebook which you do like this:

Download the certificate files from https://github.com/facebookarchive/facebook-php-sdk/blob/master/src/fb_ca_chain_bundle.crt

and add this before attempting any Facebook calls

facebook::$CURL_OPTS[CURLOPT_CAINFO] = 'path/to/fb_ca_chain_bundle.crt';

You could also try

facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;

这篇关于致命错误:未捕获CurlException:7:无法连接到第887行的src / base_facebook.php中抛出的主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆