【问题标题】:Guzzle Api Connection to EmarsysGuzzle Api 与 Emarsys 的连接
【发布时间】:2018-09-04 15:10:21
【问题描述】:

我尝试用这样的 guzzle 从 emarsys 获取联系人数据

$client = new Client([
        'base_uri' => 'www.ApiUrl.com',
    ]);

    $request = $client->request($requestType, $endPoint, [
        'query'   => $sQuery,
        'debug'   => true,
        'body'    => $sPostFields,
        'headers' => [
            'Content-type: application/json;charset="utf-8"',
        ],
    ]);

我总是收到 400 错误请求。

【问题讨论】:

    标签: api guzzle


    【解决方案1】:

    试试这个方法:

    use GuzzleHttp\Client;
    
       $client  = new \GuzzleHttp\Client(); 
        $response = $client->request('POST','www.ApiUrl.com',[
            'headers' => [
                'content-type' => 'application/x-www-form-urlencoded'
            ],
            'form_params' => [
                'name'=>$name,
                'to' =>$email,
            ],
        ]); 
    

    【讨论】:

      猜你喜欢
      • 2020-11-20
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      • 2018-06-19
      • 2017-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多