email; $fields = [ "-6ren">
gpt4 book ai didi

php - 如何使用 Laravel http post 禁用 SSL 检查

转载 作者:行者123 更新时间:2023-12-04 13:08:37 36 4
gpt4 key购买 nike

我正在尝试使用以下代码在 laravel 中向付款端点发出 post 请求

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class AddCardController extends Controller
{
//
public function index()
{
return view("addcard");
}
public function requestPayment(Request $request)
{
$paystack_key = \config("app.paystack_key");
$url = "https://api.paystack.co/transaction/initialize";
$email = $request->user("distributors")->email;
$fields = [
"email"=>$email,
"amount"=>50*100,
"channels"=>["card"],
"callback_url"=>"d"
];
$query = http_build_query($fields);
$response = Http::post($url,$fields)::withHeaders(["Authorization: Bearer $paystack_key",
"Cache-Control: no-cache",])::withOptions(["verify"=>false]);
return $response;
}
}

我收到以下错误:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.paystack.co/transaction/initialize
我在 Apache 上本地运行我的 Laravel 应用程序,所以我承认没有 SSL 运行的事实,但是我如何绕过这个错误。在生产中将提供 ssl ??

最佳答案

您应该使用 withoutVerifying()与您的 Post 请求。

  $response = Http::withoutVerifying()
->withHeaders(['Authorization' => 'Bearer ' . $paystack_key, 'Cache-Control' => 'no-cache'])
->withOptions(["verify"=>false])
->post($url,$fields);

关于php - 如何使用 Laravel http post 禁用 SSL 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68072879/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com