【问题标题】:open_basedir restriction in effect. File() is not within the allowed path(s) and Uncaught CurlException: 3: No URL set! thrown in base_facebook.phpopen_basedir 限制生效。 File() 不在允许的路径内,并且未捕获 CurlException:3:未设置 URL!在 base_facebook.php 中抛出
【发布时间】: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


    【解决方案1】:

    是的,不明显的错误消息。 但这意味着,realpath() 返回空值:

    File() 不在允许的路径内...

    确保传递给 realpath() 函数的文件确实存在于指定路径中。

    您示例中的其他异常是由此问题引起的。 顺便说一句,将所有弱点(在您的示例中 - Facebook API 调用)包装在 try-catch 块中是一种很好的做法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-23
      • 1970-01-01
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多