尝试使用Stripe API上载身份证明文件时出现以下错误。下面也给出了使用代码。请帮助! 预先感谢。
我使用的php代码是
require '.././libs/stripe-php/init.php';
\Stripe\Stripe::setApiKey('sk_test_abc123');
$fileName = "success.png";
$fp = fopen($fileName, "r");
$file_obj = \Stripe\FileUpload::create(
array(
"purpose" => "identity_document",
"file" => $fp
),
array(
"stripe_account" => 'acct_1AbC123'
)
);
$file = $file_obj->id;
$response['status'] = $file;
响应如下。
Stripe\Error\ApiConnection: Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com.
(Network error [errno 26]: couldn't open file "success.png") in C:\xampp\htdocs\stripe\libs\stripe-php\lib\HttpClient\CurlClient.php:277
Stack trace:
#0 C:\xampp\htdocs\stripe\libs\stripe-php\lib\HttpClient\CurlClient.php(234): Stripe\HttpClient\CurlClient->handleCurlError('https://uploads...', 26, 'couldn't open f...', 0)
#1 C:\xampp\htdocs\stripe\libs\stripe-php\lib\HttpClient\CurlClient.php(196): Stripe\HttpClient\CurlClient->executeRequestWithRetries(Array, 'https://uploads...')
#2 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiRequestor.php(271): Stripe\HttpClient\CurlClient->request('post', 'https://uploads...', Array, Array, true)
#3 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiRequestor.php(60): Stripe\ApiRequestor->_requestRaw('post', '/v1/files', Array, Array)
#4 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiOperations\Request.php(56): Stripe\ApiRequestor->request('post', '/v1/files', Array, Array)
#5 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiOperations\Create.php(23): Stripe\ApiResource::_staticRequest('post', '/v1/files', Array, Array)
#6 C:\xampp\htdocs\stripe\v1\index.php(318): Stripe\FileUpload::create(Array, Array)
#7 [internal function]: {closure}()
#8 C:\xampp\htdocs\stripe\libs\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)
#9 C:\xampp\htdocs\stripe\libs\Slim\Slim.php(1355): Slim\Route->dispatch()
#10 C:\xampp\htdocs\stripe\libs\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#11 C:\xampp\htdocs\stripe\libs\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#12 C:\xampp\htdocs\stripe\libs\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#13 C:\xampp\htdocs\stripe\libs\Slim\Slim.php(1300): Slim\Middleware\PrettyExceptions->call()
#14 C:\xampp\htdocs\stripe\v1\index.php(745): Slim\Slim->run()
#15 {main}{"status":"3"}
为了确认文件在那里。我使用了以下代码
$ fileName =“ success.png”;
if (!file_exists($fileName))
{
echo "Cannot find file.";
} else {
$fp = fopen($fileName, "rt")or die("Unable to open");
echo "b".var_dump($fp);
}
响应是“(流)类型的bresource(108)”,这意味着文件存在。如果我错了,请纠正我。
谢谢
答案 0 :(得分:0)
我自己找到了解决方案。问题在于本地服务器上的TLS版本1.1。在Windows 10操作系统上,您可以按照以下给定步骤选择要使用的TLS版本。 1.从控制面板打开Internet选项 2.选择高级选项卡 3.滚动到底部,您可以在其中找到TLS版本的复选框。
请注意,此解决方案是我为Windows localhost找到的。 谢谢。