我正在尝试向客户端应用程序接口(https://apidocs.getresponse.com/v3/case-study/adding-contacts)发出POST请求,并将/OAuth2-client和adespresso/oauth2-getresponse作为提供者,如下所示:
$data = [
'email' => $email,
'campaign' => [
'campaignId' => $campId
]
];
$request = $this->provider->getAuthenticatedRequest(
'POST',
'https://api.getresponse.com/v3/contacts',
$this->getMyAccessToken(),
$data
);
$response = $this->provider->getParsedResponse($request);我也尝试过在头文件中传入application/json的内容类型值,但都没有用。
$data = [ 'email' => $email, 'campaign' => [ 'campaignId' => $campId ] ];
`$options['body'] = json_encode($data);
$options['headers']['Content-Type'] = 'application/json';
$options['headers']['access_token'] = $this->getMyAccessToken();
$request = $this->provider->getAuthenticatedRequest(
'POST',
'https://api.getresponse.com/v3/contacts',
$options
);
$response = $this->provider->getParsedResponse($request); `但是,这两种方法中的getParsedResponse函数都会返回以下内容:
League \ OAuth2 \ Client \ Provider \ Exception \ IdentityProviderException (400) UnsupportedContentTypeheader.发布于 2018-11-09 16:27:05
我知道很晚了,但是试试这个代码:
$data = array(
'email' => $email,
'campaign' => array([
'campaignId' => $campId
])
);
$options['body'] = json_encode( $data );
$options['headers']['Content-Type'] = 'application/json';
$options['headers']['Accept'] = 'application/json';
$request = $this->provider->getAuthenticatedRequest( 'POST', 'https://api.getresponse.com/v3/contacts', $this->getMyAccessToken(), $options );
$response = $this->provider->getParsedResponse( $request );发布于 2020-03-14 00:30:15
使用json_encode()传递POST数据对我不起作用,我尝试了不同的解决方案,但这是唯一对我起作用的方案
$postData = [
'date' => $date,
'service_ids' => $serviceId,
];
$options = [
'body' => http_build_query($postData),
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
],
];
$request = $this->provider->getAuthenticatedRequest("POST", $requestUrl, $token, $options);
$response = $this->provider->getParsedResponse($request);https://stackoverflow.com/questions/52718933
复制相似问题