doonbfez815298 2017-01-04 05:40
浏览 23

通过PHP URL传递数据收集

suppose I have $data, which is a collection of entire data of a table, is it possible to pass this collection type data in parameters via URL from view to controller?

I'm using Laravel. All the solutions I've been searching only for array type data. Thanks for help!

  • 写回答

2条回答 默认 最新

  • douchensou6969 2017-01-04 05:51
    关注

    You can. First install the package guzzlehttp/guzzle. then try this way:

    use GuzzleHttp\Client;
    
    $client = new Client();
    $sampleData = ['name' => 'billy', 'email' => 'billy@example.com']; // your collection
    $url = 'http://api.example.com/bla-bla'; // your url
    
    $res = $client->request('POST', "{$url}",['form_params' => $sampleData]);
    $data = json_decode(json_encode($res->getBody()->getContents()),true);
    return $data;
    
    评论

报告相同问题?