Сначала создайте медиа-объект и, используя идентификатор мультимедиа, загрузите медиафайлы, но не загружайте их ниже, загрузив мой код.
Код: Выделить всё
$file = getWasabiPresignedUrl($request->media[0]);
$filePath = Str::random(8) . '-' . time() . '.' . explode('?', pathinfo($file, PATHINFO_EXTENSION))[0];
urlImageGet($file, 'temp/' . $filePath);
$imagePath = Storage::path('temp/' . $filePath);
$uploadMediaUrl = $this->api_url . 'media/'.$mediaId.'/upload';
$ch = curl_init();
if (function_exists('curl_file_create')) {
$cFile = curl_file_create($imagePath);
} else {
$cFile = '@' . realpath($imagePath);
}
$post = array( 'file' => $cFile);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'CURL_callback');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$uploadMediaResponse = curl_exec($ch);
if (curl_errno($ch)) {
$msg = curl_error($ch);
}
curl_close($ch);
i want to upload image in snapchat api and after upload video using chunk.can anyone help me ?
thank you for your supported in advanced.
Источник: https://stackoverflow.com/questions/781 ... apchat-api