cómo convertir esta solicitud de curl
solicitud de rizo
curl -L -F 'Request={"APIRequests": [{"Verb":"UploadModelRelease","AuthToken":"","FirstName":"John","LastName":"Smith","Gender ":"0","AgeGroup":"1","Ethnics":"0","Country":"44"}]}' -F 'PropertyRelease=@Documents/jamie.pdf' https://api2.dreamstime.com/api/para engullir solicitud http
guzzlecode
$client = new \GuzzleHttp\Client(); $response = $client->request('POST', "https://api2.dreamstime.com/api/",[ 'json'=>[ 'APIRequests' => [ [ "Verb" => "UploadRelease", "AuthToken" => $this->getAccessToken(),//token "ModelRelease" => $file,//file path "FirstName" => $firstName, "LastName" => $lastName, "Gender" => $gender, "Country" => $country, "AgeGroup" => $ageGroup, "Ethnics" => $ethnics, ], ], ] ]);error "por favor cargue un archivo de versión"
He escrito una consulta más cercana a la solicitud de curl, ya que la solicitud de curl tiene una -F con archivo que significa que está enviando un archivo, necesitará varias partes. Como no lo he probado, no puedo garantizar que funcione.
/** curl -L -F 'Request={"APIRequests": [{"Verb":"UploadModelRelease","AuthToken":"","FirstName":"John","LastName":"Smith","Gender ":"0","AgeGroup":"1","Ethnics":"0","Country":"44"}]}' -F 'PropertyRelease=@Documents/jamie.pdf' https://api2.dreamstime.com/api/ */ $client = new \GuzzleHttp\Client(); $response = $client->request('POST', "https://api2.dreamstime.com/api/",[ 'multipart' => [ [ 'name' => 'Request', 'contents' => '{ "APIRequests": [{"Verb":"UploadModelRelease","AuthToken":"","FirstName":"John","LastName":"Smith","Gender ":"0","AgeGroup":"1","Ethnics":"0","Country":"44"}] }' // place your json_encode here inplace of above ], [ 'name' => 'PropertyRelease', 'contents' => fopen("/path/to/file", "r") ] ] ]);