1
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 のこのコードで問題が発生しました。

コード全体はこちらです。私が毎回取得するのは、この2つのエラーだけです-

1.警告: curl_setopt_array() [function.curl-setopt-array]: open_basedir 制限が有効です。File() は許可されたパス内にありません: (/home/:/usr/lib/php:/tmp) 行 802 の /home/a2424901/public_html/base_facebook.php

2. Uncaught CurlException: 3: URL が設定されていません! /home/a2424901/public_html/base_facebook.php の 814 行目にスローされます

これが私のFacebookアプリie(index.php)のコードです

4

1 に答える 1

1

そう、自明ではないエラー メッセージです。しかし、それはrealpath()が空の値を返すことを意味します:

File() は許可されたパス内にありません...

realpath() 関数に渡されたファイルが、指定されたパスに実際に存在することを確認してください。

あなたの例の他の例外は、この問題が原因でした。ちなみに、すべての弱点 (この例では Facebook API 呼び出し) を try-catch ブロックでラップすることをお勧めします。

于 2012-05-10T09:13:50.673 に答える