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 http://www.scribd.com/developers 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.
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”
</pre> <?php require_once 'scribd.php'; <pre>$api="API Key"; $secret="API Secretj"; $scribd=new Scribd($api,$secret);</pre> $api="7fs5j960mfy4seft72lbj"; $secret="7fs5j960mfy4seft72lbj"; $scribd=new Scribd($api,$secret); //Object Created //print_r($scribd); $doc_type=$fileExt; $access=null; $rev_id=null; $data=$scribd->upload($fileLoc,$doc_type,$access,$rev_id); <pre> /* $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.