scribd form ASP

3 views
Skip to first unread message

jos verhoeff

unread,
Oct 20, 2009, 1:51:13 AM10/20/09
to Scribd Platform Talk
Hi,

I'm trying to get the Scribd API to work from ASP code. All works
fine, except uploading a file.
I tried the UploadFromURL method, bt that does not work so great, so
I'm trying to get the upload method to work:


I have a simple form in test.asp:


<FORM id=uploadform METHOD=POST enctype="multipart/form-data"
ACTION="test2.asp" >
<INPUT type="hidden" name="method" id="method" value="docs.upload">
<INPUT type="hidden" name="api_key" name="api_key"
value="xxxxxxxxxxxxxxxxxxx">
<INPUT type=file name="file" id="file">
<input type=submit>
</form>

If I fill in http://api.scribd.com/api as the action target there is
no problem, the file uploads and gets converted, but obviously I want
to get the result back and parse it, so I coded the following in
test2.asp


bytecount = request.totalbytes
requestbin = request.BinaryRead(bytecount)
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", "http://api.scribd.com/api", false
xmlhttp.setRequestHeader "Content-Type", "MULTIPART/FORM-DATA"
xmlhttp.setRequestHeader "Content-Length", bytecount
xmlhttp.send requestbin
Response.write xmlhttp.responseText
set xmlhttp = nothing


I tried using different versions of the object, I tried converting the
binary request to a string but al i get is :

500 Internal Server Error

If I print the converted data (basically what I'm sending) I get the
following:

-----------------------------21015113118230 Content-Disposition: form-
data; name="method" docs.upload
-----------------------------21015113118230 Content-Disposition: form-
data; name="api_key" xxxxxxxxxxxxxxx
-----------------------------21015113118230 Content-Disposition: form-
data; name="file"; filename="British_health_hazards_0.89.doc" Content-
Type: application/msword ÐÏ à¡± á

can anyone tell me what I can do to get something else than "internal
server error" ??

dscott

unread,
Oct 20, 2009, 1:29:55 PM10/20/09
to Scribd Platform Talk
Hi Jos:

It looks like the data is there based on your data dump so not sure if
it would make any difference, but have you tried putting the
parameters in the query string of the POST in test2.asp, rather than
passing them as hidden form values from test.asp?

E.G.:
xmlhttp.open "POST", "http://api.scribd.com/api?
method=docs.upload&api_key=xxxxxxxxxxxxxxxxxxx", false

Again, not sure what difference it would make, but at least this has
the advantage of not exposing the api_key in the source of test.asp...

-Daryl


On Oct 20, 1:51 am, jos verhoeff <j...@cerium.nl> wrote:
> Hi,
>
> I'm trying to get the Scribd API to work from ASP code. All works
> fine, except uploading a file.
> I tried the UploadFromURL method, bt that does not work so great, so
> I'm trying to get the upload method to work:
>
> I have a simple form in test.asp:
>
>         <FORM  id=uploadform METHOD=POST enctype="multipart/form-data"
> ACTION="test2.asp" >
>         <INPUT type="hidden" name="method" id="method" value="docs.upload">
>         <INPUT type="hidden" name="api_key" name="api_key"
> value="xxxxxxxxxxxxxxxxxxx">
>         <INPUT type=file name="file" id="file">
>         <input type=submit>
>         </form>
>
> If I fill inhttp://api.scribd.com/apias the action target there is
Reply all
Reply to author
Forward
0 new messages