Как загрузить файл с помощью API-интерфейса nitroflare python - PullRequest
0 голосов
/ 25 апреля 2020

Я пытаюсь написать API загрузки Nitro-flare в python, но он не работает должным образом и ничего не загружается в мой аккаунт

на оригинальном веб-сайте. У них есть пример для PHP и я прочитал статью, python версия, которую я написал, находится здесь:

import requests 

action_api_url = 'http://nitroflare.com/plugins/fileupload/getServer'

#Get a server URL
rp = requests.post(action_api_url,data={'user':'User_hash'}, allow_redirects = True, timeout = 5, )
print(rp.text)

# upload file using server URL generated previews step
upload_rp = requests.post(rp.text, data={'user':'User_hash'}, headers={'Slug': os.path.basename(filename)})

print(upload_rp.text)

результат:

http://134.19.180.50:81/index.php

{"files":[{"name":"1587765880-5344","size":45,"type":"application\/x-www-form-urlencoded"}]}

Примечание пример PHP есть:

<?php
$target_url = file_get_contents('http://nitroflare.com/plugins/fileupload/getServer');

$file = realpath('myfile.zip');
$post = array('files' => curl_file_create($file), 'user' => 'aa9201c9437878583820ba04bd16c94f8729f6da');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec ($ch);
curl_close ($ch);

var_dump(json_decode($result));

...