所以我试图整合我的应用程序与Facebook,我使用默认的example.php的代码作为我的index.php。我已经改变了appID和appSecret,以匹配我的应用程序的ID和秘密,每当我测试Facebook上的代码时,它会抛出一个异常,即UnhandledCurlException。只要我调用getUser()方法,用try和catch包装代码将只返回0。启用curl扩展在php for 000webhost.com
我知道我可以在php.ini上启用curl扩展,但是我只能在我的本地主机上找到,而不是在我用来部署我的应用的服务器(000webhost.com)上。
我也听说可以使用.htaccess文件来显式修改php配置并因此启用curl扩展,任何人都知道如何做到这一点?或者我还有其他的选择吗?
这是抛出错误的功能: 保护功能makeRequest的($网址,$参数,可以$ CH = NULL){ 如果(!$ CH){$ CH = curl_init(); }
$opts = self::$CURL_OPTS;
if ($this->getFileUploadSupport()) {
$opts[CURLOPT_POSTFIELDS] = $params;
} else {
$opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
}
$opts[CURLOPT_URL] = $url;
// disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
// for 2 seconds if the server does not support this header.
if (isset($opts[CURLOPT_HTTPHEADER])) {
$existing_headers = $opts[CURLOPT_HTTPHEADER];
$existing_headers[] = 'Expect:';
$opts[CURLOPT_HTTPHEADER] = $existing_headers;
} else {
$opts[CURLOPT_HTTPHEADER] = array('Expect:');
}
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
$errno = curl_errno($ch);
// CURLE_SSL_CACERT || CURLE_SSL_CACERT_BADFILE
if ($errno == 60 || $errno == 77) {
self::errorLog('Invalid or no certificate authority found, '.
'using bundled information');
curl_setopt($ch, CURLOPT_CAINFO,
dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fb_ca_chain_bundle.crt');
$result = curl_exec($ch); //the line 1003
}
// With dual stacked DNS responses, it's possible for a server to
// have IPv6 enabled but not have IPv6 connectivity. If this is
// the case, curl will try IPv4 first and if that fails, then it will
// fall back to IPv6 and the error EHOSTUNREACH is returned by the
// operating system.
if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
$matches = array();
$regex = '/Failed to connect to ([^:].*): Network is unreachable/';
if (preg_match($regex, curl_error($ch), $matches)) {
if (strlen(@inet_pton($matches[1])) === 16) {
self::errorLog('Invalid IPv6 configuration on server, '.
'Please disable or get native IPv6 on your server.');
self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$result = curl_exec($ch);
}
}
}
if ($result === false) {
$e = new FacebookApiException(array(
'error_code' => curl_errno($ch),
'error' => array(
'message' => curl_error($ch),
'type' => 'CurlException',
),
));
curl_close($ch);
throw $e;
}
curl_close($ch);
return $result;
}
它返回1,但是当我测试我的本地主机时,它也返回1(启用和禁用)。 –
'(启用和禁用)“我不明白。 –
这意味着我测试你的php代码与我的本地主机,我测试了两次,第一次通过启用扩展和第二次禁用扩展(通过评论它),并且两个结果返回1. –