2

我正在尝试从 api 获取地理编码并在我的数据库中针对地址条目进行更新。我正在通过 laravel 中的种子类运行它。

正在使用 Guzzle 进行异步调用。我想异步运行 api 调用,同时我想在后台读取异步响应并在数据库中更新它们。

$client = new \GuzzleHttp\Client();
//retrieve the the latitude and longitude from geocode.farm of the given address
$response = $client->get('http:........<url for json request goes here>',['future' => true]);
$response->then(function ($response) {
  // in here I read the $response object and get the latitude /longitude to update in the database.

// 我在这里尝试回显和打印,脚本似乎没有在这个回调函数中进入这里 });

我在循环中调用上面的代码行。上面的脚本在我进行同步调用时运行良好,但在异步调用中我无法运行它?你能帮我吗?

脚本似乎没有进入回调函数

4

0 回答 0