下面是我在DEV环境下成功的HTTP请求:
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Accept' => 'application/json'
])
->withToken('xxxxxxxxxxxxxx')
->post('https://xxxxxxxxx.com/v0.1/messages/', [
'from' => [
'type' => 'xxxx',
'number' => 'xxxxxxxx',
],
'to' => [
'type' => 'xxxxx',
'number' => 'xxxxxx',
],
'message' => [
'content' => [
'type' => 'text',
'text' => 'test message from laravel'
]
]
]);但在生产环境中,必须向请求添加代理。
有没有人知道如何用上面的请求传递代理?提前谢谢你。
发布于 2021-03-29 07:13:19
可以使用withOptions方法指定阵列图选项。
因此:
$response = Http::withOptions([
'proxy' => 'http://username:password@proxyhost.com:7000'
])->withHeaders( ...https://stackoverflow.com/questions/62189974
复制相似问题