Skip to content

Instantly share code, notes, and snippets.

@prodhan
Created April 22, 2020 19:28
Show Gist options
  • Save prodhan/28299be19bdcd8d52da0c7269a8cff36 to your computer and use it in GitHub Desktop.
Save prodhan/28299be19bdcd8d52da0c7269a8cff36 to your computer and use it in GitHub Desktop.
<?php
$client = new Client();
try {
$response = $client->request('POST', $uri, [
'headers' => ['Accept' => 'application/json', 'Content-type' => 'application/json', 'Authorization' => $apikey],
['body'=>json_encode($myBody)],
'multipart' => [
[
'Content-type' => 'multipart/form-data',
'name' => 'file',
'contents' => $file,
'filename' => 'filename.jpg',
]
],
]);
}
catch (ClientException $e){
return $e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment