Scribd API

This is going to my first post. I am currently building a site for checking plagiarism among projects uploaded in my site.

When building a site, i encountered a problem for viewing files of different formats like “.docx”, .”pptx”, “.doc”, “.ppt”, .pdf” and many. First i tried to read contents from a word document (“doc”) which i was able to succeed using anti-word. Then i tried to read contents form “.docx” and then i came to know that “.docx” is a zip and we can read contents from “word/document.xml” using PHP.

PHP has facility to read a .zip file. But in all these cases, i was able to get only the plain text and could display with their formatting. Indeed, i don’t know about and i couldn’t find a solution. Then in web i goggled for “ embedding the files “ in our webpage. Through that i came know about “scribd API” and several other API’s for “embedding the files”.

About Scribd API

I honestly don’t know much about this API. I just saw in how to integrate in our website. For using API, we need to signup for a free API account. After signing up, under the account setting in the API tab look up your “API key” and “API Secret” id.

Second Step:

Now download Scribd.php  from the site. There is a nice tutorial available in scribd developers site also about using scribd. php. Here, i will just say how to upload the doc using scribd API and how to retrieve using javascript.

Uploading a doc using Scribd API:

1) include scribd.php in your php file

2) Create a scribd object using “scribd(api_key,api_secret)”

3) Then use scribd->upload(“filename”,”file_ext”,”access”,”rev_id”);

4) On successful upload scribd API will return “doc_id” and “access_key”


require_once 'scribd.php';
<pre>$api=&quot;API Key&quot;;
$secret=&quot;API Secretj&quot;;

$scribd=new Scribd($api,$secret);</pre>

$scribd=new Scribd($api,$secret);
 //Object Created



/* $fileExt - Type of file to be uploaded
	$fileLoc - Completer path of file


5) After uploading $doc will contain an array consisting of “doc_id” and “access_key”.

Note: file Name should be complete. Your PHP version must support curl. Download the latest version of PHP.

Continue reading