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.

Viewing The Uploaded Document:

This is accomplished using the javascript.

Refer and to get a clear-cut idea.

My script for reading doc goes here:

<script type="text/javascript">
function GetDoc(doc_id,a_key)
  var scribd_doc = scribd.Document.getDoc(doc_id, a_key);

  var onDocReady = function(e){

  scribd_doc.addParam('jsapi_version', 2);
  scribd_doc.addEventListener('docReady', onDocReady);
   scribd_doc.addParam('height', 600);
  scribd_doc.addParam('width', 400);
  scribd_doc.addParam('public', true);

In my script, when GetDoc(docid,accesskey) is called, the document is written in id called “embedded doc”

Thank you 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s