Vll sind nicht alles gültige Videodateien was du da hochschiebst?
Meine Überlegung war ob es Files sind die "auf ner internen Blacklist stehen". Deswegen hab ich die Datei mal über den Webupload hochgeladen, der Upload war zwar langsam ging aber ohne weitere Probleme durch.
@ Jana-Maria. Guter Punkt. Sind aber MKV Files
Edit war hier:
Ich lade via PHP / Curl hoch.
Es wird ein Login getätigt der auch klappt. Ich fische mir die Session aus der Rückgabe (Header) und sende diese als "session" beim post auf https://vivo.sx/push mit, Cookies werden auch mitgesendet
Relevanter Code zum nachvollziehen der Geschichte
Erstmal drei Funktionen die für die Anfrage zuständig sind:
PHP-Code:
function cookie($url) {
return BASEPATH.'cookies/'.parse_url($url, PHP_URL_HOST).'.cookie';
}
PHP-Code:
function mime_type($file){
return 'video/x-matroska';
}
PHP-Code:
function request($url, $data = array(), $enableCookies = true, $redirect = false, $file = null) {
$ch = curl_init($url);
$userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0';
if($enableCookies) {
curl_setopt($ch, CURLOPT_COOKIEFILE, cookie($url));
curl_setopt($ch, CURLOPT_COOKIEJAR, cookie($url));
}
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); // empty user agents probably not accepted
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $redirect);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // enable this - they check referer on POST
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if($file) {
if(!file_exists($file))
{
throw new Exception('File not found');
}
$mt = mime_type($file);
if(is_array($mt)){
throw new Exception("[error] mimetype failed for {$file} with message ".$mt['message']."\n");
}
$curl_file = new CurlFile(realpath($file), $mt, basename($file));
$data['file'] = $curl_file;
}
if(count($data)) {
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
#curl_setopt($ch, CURLOPT_HEADERFUNCTION, "curlResponseHeaderCallback");
$response = curl_exec($ch);
$cookies = curl_getinfo($ch, CURLINFO_COOKIELIST);
$result = array(
'contents' => $response,
'request' => array(
'statusCode' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
'info' => curl_getinfo($ch),
'cookies' => $cookies
)
);
curl_close($ch);
return $result;
}
Die Funktion die dann den Upload macht
PHP-Code:
<?php
function vivo_upload($file) {
global $cookies;
if(!file_exists($file)) throw new Exception('File not found');
$data['action'] = 'login';
$data['mail'] = '';
$data['password'] = '';
$response = request('https://vivo.sx/request', $data, true);
$json = json_decode($response['contents'], true);
if(!$json['status']) {
throw new Exception('[vivo.sx] Login failed');
}
$sid = str_replace('session=', '', $cookies[1]);
var_dump($sid);[COLOR="#FF0000"] <-- korrekt[/COLOR]
#exit();
$data = array();
$data['action'] = 'upload';
$data['session'] = $sid;
$data['size'] = filesize($file);
$response = request('https://vivo.sx/push', $data, true);
echo "<pre>";
print_r($response);
[COLOR="#FF0000"]// hier gibt es einen 403 (forbidde) nicht immer aber sehr sehr oft
[/COLOR]
$server = json_decode($response['contents'], true);
if(json_last_error() != JSON_ERROR_NONE)
{
throw new Exception('[vivo.sx] Upload Pre Step failed');
}
$data = array(
'Filename' => basename($file),
'session' => $sid,
'name' => basename($file),
'Upload' => 'Submit Query',
'action' => 'push',
);
$response = request($server['PUSH'], $data, true, true, $file);
var_dump($response['contents']);
return (filter_var($response['contents'], FILTER_VALIDATE_URL) ? $response['contents'] : false );
}
$plugin_functions['vivo.sx'] = 'vivo_upload';
403 ist kein forbidden sondern nen access denied error