Son 2 problemas xD
¿Que estoy haciendo mal?
Código
import urllib2,sys,re nave = urllib2.build_opener() nave.add_header = [('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5')] def tomar(web,vars) : return nave.open(web,vars).read() () def chubir(): print "[+] Uploading file\n" try: code = tomar("http://www.imageshack.us/upload_api.php","key=268BEKSV9465b858a45cd1b4d2b32d1195ee6f27","a_username=elektrohacker","a_password=MIPASSWORD","fileupload=C:/1.jpg") #code = tomar("http://www.imageshack.us/upload_api.php","fileupload="+str(lin)+"&submit=submit") except: print "[-] Page offline\n" if re.findall("Bad API request",code): print "[-] Error uploading file\n" else: print "[+] Enjoy : ",code+"\n" () chubir() # Fin
EDITO:
También lo he intentado por Ruby, Que me resultaría más fácil porque lo conozco un poco más que Python:
Código
require "net/http" def tomar(web,par) return Net::HTTP.post_form(URI.parse(web),par).body end def subir() print "[+] Uploading file\n\n" code = tomar("http://www.imageshack.us/upload_api.php",{"fileupload"=>"C:/1.jpg","key"=>"268BEKSV9465b858a45cd1b4d2b32d1195ee6f27","submit"=>"submit"}) # code = tomar("http://www.imageshack.us/upload_api.php",{"fileupload"=>ARGV[1],"key"=>"268BEKSV9465b858a45cd1b4d2b32d1195ee6f27","submit"=>"submit"}) print "[+] Enjoy : "+code+"\n" end subir()
Me da este error:
Código:
<error id="parameter_missing">Sorry, but we've detected that unexpected data is
received. Required parameter 'fileupload' is missing or your post is not multipa
rt/form-data</error>
</links>
Se que estoy intentando por el método POST, Pero en la documentación de Imageshack pone que se puede por POST, Y no se como hacer la conexión para multipart...
También lo he intentado con curl para Windows:
Código
curl.exe -F xml=yes -F "fileupload=c:\1.jpg" http://www.imageshack.us/index.php
Me dice que necesito introducir la developer key, Pero no se como ponerla, con que sintaxis en curl...
Porfavor, Si alguien además me pudiera ayudar con los parámetros de la API, O simplemente decirme si lo estoy haciendo bien o no los parámetros de la APi se lo agradecerñia mucho, Aquí está la info:
Citar
Unified API entry point is: http://www.imageshack.us/upload_api.php for images
Supported parameters are:
fileupload; (input type="file") - image or video file. Mandatory unless url parameter is specified.
frmupload; (input type="file") - video default frame picture. Optional, used only for video upload.
url; This parameter indicates that transload method is used instead of upload
optsize; resize options for image in form WxH if image is uploaded/transloaded. No impact on video uploads.
rembar; Developer could tell to ImageShack to leave/remove information bar on thumbnail image generated by ImageShack . If you've supplied this parameter as yes or as 1 then generated thumbmail will have no information bar.
tags; A comma-separated list of tags to add to your video/image. E.g. family,picture. Optional
public; Public/private marker of your video/picture. yes means public (default), no means private. Optional
cookie; Registration code, optional.
a_username; Username, optional.
a_password; Password, optional.
key; Your DeveloperKey. Mandatory.
Supported parameters are:
fileupload; (input type="file") - image or video file. Mandatory unless url parameter is specified.
frmupload; (input type="file") - video default frame picture. Optional, used only for video upload.
url; This parameter indicates that transload method is used instead of upload
optsize; resize options for image in form WxH if image is uploaded/transloaded. No impact on video uploads.
rembar; Developer could tell to ImageShack to leave/remove information bar on thumbnail image generated by ImageShack . If you've supplied this parameter as yes or as 1 then generated thumbmail will have no information bar.
tags; A comma-separated list of tags to add to your video/image. E.g. family,picture. Optional
public; Public/private marker of your video/picture. yes means public (default), no means private. Optional
cookie; Registration code, optional.
a_username; Username, optional.
a_password; Password, optional.
key; Your DeveloperKey. Mandatory.