# Mental Masturbation, Musings, and Methods

## PHP and Acrobat.com

#### June 5th, 2008 · 2 Comments

Anyway, regardless of the poor GUI congruity, I would like to discuss the API.  The site has a few public libraries at first appearance, and I must hand it to Adobe that their Java library looks extremely clean and easy to use.  But the Python library – not even a library, although probably the easiest reading of all of their online documentation.  The writer of the blog even states that he has given up and decided to use the Java library –  encouraging.  Anyway, disappointed in not even an attempt at a PHP implementation, I decided to give it a shot.  I essentially went as far as the writer of the Python blog post: authenticate, get sessionid, and get a list of files you have on your account.  (Note this requires PEAR’s HTTP_Request package.) Also, I know this is very ugly code and I’m possitive could and should be done much cleaner.  However, it works if your just trying to take the first steps and get some output.  If anyone wants to clean it up or continue on with a PHP implementation, feel free and let me know how it goes.  However, until they open up the platform to worthwhile features, it is sadly not worth my time.  Hopefully Adobe soon realizes the mistake of being so possessive and thinks a little more creatively about how to monetize their technology.  Anyway, here is the code; enjoy:

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82  < ?php $acrobat_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";$acrobat_shared_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $acrobat_base_url = "https://api.share.acrobat.com/webservices/api/v1/";$acrobat_username = "your_username@somecompany.com"; $acrobat_password = "your_acrobat.com_password"; function getAuthToken() { global$acrobat_api_key, $acrobat_shared_secret,$acrobat_base_url, $acrobat_password,$acrobat_username; $a = new HTTP_Request();$a->setURL($acrobat_base_url."auth/");$a->setMethod("POST"); $time = time();$data = "POST https://api.share.acrobat.com/webservices/api/v1/auth/ ".$time;$md5 = md5($data.$acrobat_shared_secret); $auth = "AdobeAuth apikey=\"".$acrobat_api_key."\",data=\"".$data."\",sig=\"".$md5."\""; $request_body = "\n".$acrobat_username."\n".$acrobat_password."\n";$a->addHeader("Authorization", $auth);$a->setBody($request_body);$a->sendRequest(); $xml =$a->getResponseBody(); $regex = "[a-zA-Z0-9]+";$i = ereg($regex,$xml, $matches);$p = xml_parser_create(); $i = xml_parse_into_struct($p, $matches[0],$vals, $index);$j = xml_parser_free($p); return$vals[0]['value']; } function getSession($auth_token) { global$acrobat_api_key, $acrobat_shared_secret,$acrobat_base_url; $a = new HTTP_Request();$a->setURL($acrobat_base_url."sessions/");$a->setMethod("POST"); $time = time();$data = "POST https://api.share.acrobat.com/webservices/api/v1/sessions/ ".$time;$md5 = md5($data.$acrobat_shared_secret); $auth = "AdobeAuth apikey=\"".$acrobat_api_key."\",data=\"".$data."\",sig=\"".$md5."\""; $request_body = "\n".$auth_token."\n"; $a->addHeader("Authorization",$auth); $a->setBody($request_body); $a->sendRequest();$xml = $a->getResponseBody();$regex = "[a-zA-Z0-9]+"; $i = ereg($regex, $xml,$matches); $p = xml_parser_create();$i = xml_parse_into_struct($p,$matches[0], $vals,$index); $j = xml_parser_free($p);   $regex = "[a-zA-Z0-9]+";$i = ereg($regex,$xml, $matches2);$p = xml_parser_create(); $i = xml_parse_into_struct($p, $matches2[0],$vals2, $index);$j = xml_parser_free($p);$response[0] = $vals[0]['value'];$response[1] = $vals2[0]['value']; return$response; } function getList($session,$secret) { global $acrobat_api_key,$acrobat_shared_secret, $acrobat_base_url;$a = new HTTP_Request(); $a->setMethod("GET");$time = time(); $data = "GET /webservices/api/v1/dc/ apikey=".$acrobat_api_key." calltime=".$time." sessionid=".$session; $md5 = md5($data.$secret);$url = $acrobat_base_url."dc/?apikey=".$acrobat_api_key."&calltime=".$time."&sessionid=".$session."&sig=".$md5;$a->setURL($url);$a->sendRequest(); $xml =$a->getResponseBody(); return $xml; }$auth = getAuthToken(); $response = getSession($auth); $session =$response[0]; $secret =$response[1]; echo getList($session,$secret); ?>

### 2 responses so far ↓

• 1 professional teeth whitening // Sep 25, 2014 at 4:15 pm

We are a gaggle of volunteers and opening a
new scheme in our community. Your website provided
us with useful information to work on. You’ve performed a formidable process and our entire neighborhood will likely be grateful to you.

• 2 Merry // Oct 10, 2014 at 12:57 am

An outstanding share! I’ve just forwarded this onto a friend who was doing
a little research on this. And he in fact bought me lunch due to the
fact that I stumbled upon it for him… lol. So let me reword this….
Thanks for the meal!! But yeah, thanx for spending some
time to discuss this subject here on your web site.