Facebook graph api FB API PHP curl_setopt_array():不推荐使用@filename API上传文件

Facebook graph api FB API PHP curl_setopt_array():不推荐使用@filename API上传文件,facebook-graph-api,facebook-php-sdk,Facebook Graph Api,Facebook Php Sdk,FBPHPAPI和PHP5.5在上传照片到服务器时出现问题。使用方法时: private function _upload( $type = '', $path = '', $message = '', $aid = '' ) { try { if ( !in_array( $type, array( 'photos', 'videos' ) ) ) { throw new \Exception( 'Error: Inc

FBPHPAPI和PHP5.5在上传照片到服务器时出现问题。使用方法时:

 private function _upload( $type = '', $path = '', $message = '', $aid = '' ) {
        try {

            if ( !in_array( $type, array( 'photos', 'videos' ) ) ) {
                throw new \Exception( 'Error: Incorrect type ' );
            }

            if ( !self::getFB()->getUser() ) {
                throw new \Exception( 'Error: No user' );
            }

            if ( empty( $path ) ) {
                throw new \Exception( 'Error: path is empty' );
            }
            if ( !file_exists( realpath( $path ) ) ) {
                throw new \Exception( 'Error: file doesn\'t exists' );
            }


            if ( !empty( $aid ) ) {
                $url = "/" . $aid . "/" . $type;
            } else {
                $url = '/' . self::getFB()->getUser() . '/' . $type;
            }

            var_dump( array( $url, 'POST',

                    array(
                        'image'   => '@' . realpath( $path ),
                        'message' => $message,
                    )
                )
            );

            self::getFB()->setFileUploadSupport( TRUE );

            $ret_obj = self::getFB()->api( $url, 'POST', array(
                    'image'   => '@' . realpath( $path ),
                    'message' => $message,
                )
            );
            return $ret_obj[ 'id' ];
        } catch ( \Exception $e ) {
            return $e->getMessage();
        }
    }

我得到错误:curl\u setopt\u array():不推荐使用@filename API上传文件。请改用CURLFile类

您使用的是PHP5.5,使用的是通过CURL上传的旧方法。请在以下位置查看差异:

古老的 新的
您应该创建一个bug报告,要求他们更新SDK以考虑此更改,顺便问一句,这真的是一条中断您的脚本的错误消息,还是只是一个警告?(“已弃用”表示在将来某个时候将不再工作,但现在仍然有效,因此这应该只是一个警告,而不是一个脚本中断错误。)由于服务器上的设置,这将创建一个错误。
curl_setopt($curl_handle, CURLOPT_POST, 1);
$args['file'] = '@filename.png';
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl_handle, CURLOPT_POST, 1);
$args['file'] = new CurlFile('filename.png', 'image/png');
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $args);