Iは、メーカーと通信するLaravel 5フレームワークを使用しているを受信した場合、私は、コールバック受信に苦労している:ここLaravel ServerExceptionは、単純なJSON要求
は、それらの両方を設定する(経路でありますちょうど)の試験に:
Route::post('/callback', '[email protected]');
Route::get('/callback', '[email protected]');
とコントローラでの簡単な方法:
public function callback(Request $request)
{
var_dump($request);
//Storage::put('request.txt', $request);
}
それは正常に動作します私は意味(手動でサイトを開くと、それは後でリクエストをダンプし、要求ファイルを作成します)が、このようなような呼び出したとき:
ServerException in RequestException.php line 107:
Server error: `POST http://project.dev/callback` resulted in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<style>
(truncated...)
編集:私はphp_error.log
に入るのみerrorlikeメッセージは次のとおりです。
/**
* Test callback option
*/
public function testCallback()
{
$callback_url = 'http://project.dev/callback';
// Prepare response
$response = array(
'time' => -microtime(true),
);
$data = [
"id" => 907,
"current_state" => "Shipped",
"merchant_sku" => "BST123",
"ordered_on_date" => "2015-08-16T00:00:00+0200",
"ship_by_date" => "2015-08-21T00:00:00+0200",
"shipping_carrier" => "USPS",
"shipping_tracking" => "9499907123456123456781",
];
try {
$result = Guzzle::post($callback_url, [
'verify' => false,
'headers' => [
'Content-Type' => 'application/json',
],
'json' => $data,
]);
$body = json_decode($result->getBody(), true);
// Fill response
if ($body['success'] == true) {
$response['success'] = true;
$response['order_id'] = $body['work_order_id'];
} else {
$response['success'] = false;
}
} catch (Exception $e) {
// Set error
$response['success'] = false;
$response['message'] = $e->getMessage();
}
// Save execution time
$response['time'] += microtime(true);
$response['time'] = round(abs($response['time']), 4);
return $response;
}
は、私は、このエラーメッセージが表示されます
[09-May-2016 12:24:20 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
私が間違ってやっていることや、これをデバッグして修正する方法はありますか?
ところで、通信はセーブマシンの2つのラーバルフレームワークの間で行われます。つまり、site.dev
の送信要求project.dev
です。
EDIT: POSTを受信すると、エラーメッセージが表示されます。それはGETで見つけることができます。私は'verify' => false
にリクエストを送信していますので、
[2016-05-09 15:21:25] local.ERROR: exception 'Illuminate\Session\TokenMismatchException' in D:\project.dev\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:67
なぜLaravelでも、この気にしますか?
たとえば、郵便配達員を使用してエラーを再現できますか? envをlocalに設定してdebugをtrueに設定すると、laravelはおそらく何が間違っているかを伝えます。 –
@FrankProvost遅く応答して申し訳ありません。私はすでにデバッグをしており、正しいエラーにつながるものは見えません。*しかし、get要求を送信すると、うまく動作します。 – Peon