[英]array_key_exists(): error Guzzle
我有一個發布的令人吃驚的方法,但我得到了錯誤
array_key_exists():
第一個參數應為字符串或整數
我的表單是一個簡單的發布方法表單
<form action="{{URL::asset('/send/confirmation')}}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" value="{{$order->id}}">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" aria-describedby="nameHelp" placeholder="Enter your name">
<small id="nameHelp" class="form-text text-muted">By adding your name you are confirming your are authorized to sign this order and any conditions.</small>
</div>
<div class="form-group">
<label for="position">Position</label>
<input type="text" class="form-control" id="position" aria-describedby="positionHelp" placeholder="Enter your position within the company">
<small id="positionHelp" class="form-text text-muted">By adding your name you are confirming your are authorized to sign this order and any conditions.</small>
</div>
<button type="submit" class="btn btngenius">Submit</button>
</form>
然后我的控制器拿起$ request對象並發送數據
//Confirm Order
public function confirmOrder(Request $request) {
$id = $request->get('id');
$name = $request->get('name');
$position = $request->get('position');
$response = (new GuzzleHttp\Client)->post(getenv('API_MICRO_URL') . '/orders/send/copy', [
'form_params' => [
'id' => $id,
'name' => $name,
'position' => $position
],
'headers' => [
'Authorization' => 'Bearer '.session()->get('token.access_token'),
'Accept' => 'application/json',
]
]);
return response('all signed up');
}
}
我直接返回該錯誤,但不確定我能看到什么錯誤
進行以下更改:
$id = $request->id;
$name = $request->name;
$position = $request->position;
您尚未在FORM內的任何這些輸入字段中設置名稱屬性:
<input type="hidden" name="id" value="{{$order->id}}">
希望為您工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.