This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Support Get Requests

automatedme wrote on 2010-07-21:
Hi,

I like pdfcrowd for it's one long page option. I want to write a google chrome extension that uses pdfcrowd to upload a pdf page directly to google docs but to do so I would need pdfcrowd to support get instead of/in addition to post requests.

Any chance of allowing this?

Currently my plugin uses pdfmyurl since it supports get requests.

Thanks.
support wrote on 2010-07-21:
We don't plan to support GET API requests in the near future, sorry.

One thing we could do is to add a new method to the API that would return a json response containing a url. You could then send a GET request to that url to retrieve the generated PDF.

The communication would look like this:

POST /api/json/convert/uri -> json response
GET response['url']


Would it help you with your extension?
automatedme wrote on 2010-07-21:
I just discovered that by watching the requests when you go through the pdfcrowd form online (I should have read your post first - forgot to choose "watch" option). This would be great to add to the official api.

I already coded up a test extension and it works perfectly. For this version I don't send token or username information, I just send the requests (which, I assume send the session cookie information along with it) using the non api version (/form/json/convert) which you must be logged in for. That simplifies my extension in some ways because I don't have to store their username and token, but then I have to detect whether they are logged in to pdfcrowd or not. If not they would have to log in first.

Anyways, it would be great if that could be added to the api version.

I had a quick question as I start writing it. My thinking right now is that I would make an option as to whether they have an account or not and if they don't, just use the /form/json/convert url with no options. Then, if they do have an account, I would use the option for one long page, landscape etc... Is that okay to do, or would you like me only to allow users with accounts to use it?

One other suggestion that would make my extension super easy... I would rather not duplicate all the options you have available and then try to keep up if you add more or change them. What would be great is if the api had a flag to use the default options saved on their account. Then they could customize it on their account and my extension would just always user their defaults.

Anyways, let me know what you think. I think pdfcrowd is the best. Thanks for creating it.

p.s. My extension used to use pdfmyurl and an undocumented google docs option, but it broke when google removed the option. Before they removed it I had around 7,000 users (after a lifehacker article). I still have around 4,000 users with the extension installed even though it is broken. So once I get it updated to use pdfcrowd, you could potentially see 4,000 - 7,000 new users. I don't know if that is small or big for your expectations and how many you already have, but I thought I would mention it.
support wrote on 2010-07-22:
We really like the idea of your chrome extension - thanks! Here is what we suggest:

For various reasons, we do not recommend using /form/json/convert/ for this purpose. Instead, we would add a new url that can be used by bookmarklets and browser extensions. The new url would behave almost identically to /form/json/convert/ except it would accept only the src field and the server would automatically apply the default options based on the sessionid cookie.

As far as the users are concerned, we don't think it is necessary to restrict your extension to registered users only, at least for the beginning.

Let us know what you think.
automatedme wrote on 2010-07-24:
That would be perfect. I have the extension (almost) written. Let me know the new urls and how to use them. It should be pretty easy for me to change it to use the new api.

Thanks a lot. I think it will be a good extension.
support wrote on 2010-07-27:
We added two new urls. Both urls authenticate the user based on the sessionid cookie.

method:  GET 
url:     /session/json/user/

response:
{ 
  "authenticated": true/false,
  "restricted":    true/false
}


If 'authenticated' is set to true then the user has an active account at Pdfcrowd and is logged in. The 'restricted' property is send only if the user is authenticated and indicates whether the user has full access to the Pdfcrowd service. This property can be ignored for now.

method:        POST
url:           /session/json/convert/uri/
content-type:  application/x-www-form-urlencoded
post data:     src - url to convert to PDF

response:
{
  "status"   : ok|error|redirect,
  "url"      : pdf-url|redirect-url,
  "message"  : error message,
  "user"     : {
      // corresponds to response from /session/json/user
      "authenticated": true/false,
      "restricted":    true/false
  }
}


It applies user's default settings and converts 'src' to PDF. On success, 'status' is set to 'ok' and 'url' points to the generated PDF. If an error occurs then 'status' is set to 'error' and 'message' contains the error description. When 'status' is set to 'redirect' then you should open 'url' in the selected or a new tab.

Notes:

  • The HTTP status code should be always 200 even if 'status' is set to 'error'.
  • It should not happen but please always check that you got a valid JSON response.
  • It would be great if you could somehow prevent the user from triggering more than one conversion in parallel - e.g. by graying out the extension button during an ongoing conversion.
  • We do not recommend to poll the user status periodically. Instead, you can retrieve the status when the extension starts via /session/json/user/ and then update it after each conversion from the 'response.user' property.


If you are interested, here is a minimalistic chrome extension example we wrote to test the urls.

That's it. Let us know how it works for you.
automatedme wrote on 2010-07-29:
That looks great! It works perfectly in my initial tests. The only thing I have left to do is some clean up, more testing, and wait for a friend to finish the icon and I'll be ready for an initial beta type release.
automatedme wrote on 2010-08-10:
I released the updated version of the extension that uses pdfcrowd. You can find it here:

https://chrome.google.com/extensions/detail/cppogeekogbladboceekjeiibihnkbhp

The project page is here:

http://code.google.com/p/send-to-docs-chrome/

Let me know what you think...

Thanks again for making the changes (and making them so quickly).
support wrote on 2010-08-11:
That's fantastic, thanks! We will put a link to your extension on our website in the comming days.

One suggestion: Our logs show that many users click the extension icon when an internal chrome url is loaded in the current tab (e.g. New Tab, Extensions, etc.). These urls start with chrome://. To save a pointless round trip to our servers it would be great if you could filter these urls out.
automatedme wrote on 2010-08-11:
Thank you for a great service.

I agree on the chrome:// requests and I just created an issue for it - http://code.google.com/p/send-to-docs-chrome/issues/detail?id=12.

Feel free to make further suggestions or bugs reports over at the project site.

Thanks again.