【发布时间】:2012-05-13 20:45:35
【问题描述】:
protected function makeRequest($url, $params, $ch=null) {
if (!$ch) {
$ch = curl_init();
}
$opts = self::$CURL_OPTS;
if ($this->useFileUploadSupport()) {
$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);
if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
self::errorLog('Invalid or no certificate authority found, '.
'using bundled information');
curl_setopt($ch, CURLOPT_CAINFO,
dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
$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;
}
我已经构建了一个 facebook 应用程序,但是 base_facebook.php 的这段代码出了点问题。
Whole code is here。我每次得到的都是这 2 个错误 -
1.警告:curl_setopt_array() [function.curl-setopt-array]:open_basedir 限制生效。 File() 不在允许的路径内:/home/a2424901/public_html/base_facebook.php 第 802 行中的 (/home/:/usr/lib/php:/tmp)
2.Uncaught CurlException: 3: 没有设置 URL!扔在 /home/a2424901/public_html/base_facebook.php 第 814 行
Here 是我的 facebook 应用程序的代码,即 (index.php)
【问题讨论】:
标签: facebook facebook-graph-api web-applications curl facebook-php-sdk