You are on page 1of 2

<?

php
include_once("scribd.php");

$UpdloadData = createIPaper("gpl.pdf","pdf","public");
$EmbedUrl = getEmbedUrl($UpdloadData);
echo $EmbedUrl;
$EmbedCode = getEmbedCode($UpdloadData);
echo $EmbedCode;

function createIPaper($File, $FileType, $Access="private")
{
$scribd_api_key = "<your API key>";
$scribd_secret = "<your Secret key>";

if (empty($FileType))
throw new Exception("Filetype cannot be empty");
$Scribd = new Scribd($scribd_api_key,$scribd_secret);

$UploadData = $Scribd->upload($File,$FileType,$Access,1);
return $UploadData;
}

function getEmbedUrl($UploadData)
{
if($UploadData){
$EmbedUrl = "http://d1.scribdassets.com/ScribdViewer.swf?
document_id={$UploadData['doc_id']}&access_key={$UploadData['access_key']}&page=1&
version=1&viewMode=list";
return $EmbedUrl;
}
}

function getEmbedCode($UploadData, $Width=450, $Height=500)
{
$EmbedCode = <<<EOD
<object
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#vers
ion=9,0,0,0"
id="doc_512761847372423" name="doc_512761847372423"
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
align="middle"
height="{$Height}"
width="{$Width}" >
<param name="movie" value="http://d1.scribdassets.com/ScribdViewer.swf?
document_id={$UploadData['doc_id']}&access_key={$UploadData['access_key']}&page=1&
version=1&viewMode=list">
<param name="quality" value="high">
<param name="play" value="true">
<param name="loop" value="true">
<param name="scale" value="showall">
<param name="wmode" value="opaque">
<param name="devicefont" value="false">
<param name="bgcolor" value="#ffffff">
<param name="menu" value="true">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<param name="salign" value="">
<param name="mode" value="list">
<embed src="http://d1.scribdassets.com/ScribdViewer.swf?
document_id={$UploadData['doc_id']}&access_key={$UploadData['access_key']}&page=1&
version=1&viewMode=list"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
play="true"
loop="true"
scale="showall"
wmode="opaque"
devicefont="false"
bgcolor="#ffffff"
name="doc_512761847372423_object"
menu="true"
allowfullscreen="true"
allowscriptaccess="always"
salign=""
type="application/x-shockwave-flash"
align="middle"
mode="list"
height="{$Height}"
width="{$Width}">
</embed>
</object>
EOD;
return $EmbedCode;
}
?>