Post

2 followers Follow
0
Avatar

Newbie with PHP and API

Are there any example scripts for connecting to clarizen?

I looked through both the Web Service and REST API guides without help.

I could really use some basic examples to understand how everything is supposed to be structured.

Josh

Josh Boutwell Answered

Please sign in to leave a comment.

3 comments

0
Avatar

Hi Josh,
The Web Services API documentation does contain PHP samples. Please review:
https://success.clarizen.com/hc/en-us/articles/205711818-16-12-Web-Service-API-Guide-Version-2
Obviously you'll need the PHP SoapClient enabled.

The REST API does not contain any language/platform specific samples, because it's simply about sending well structured JSON messages through HTTP (and decoding the JSON results), so the documentation focuses in messages structure.
I suggest you Google "using rest api with php" (not Clarizen specific) to find some answers.

Hope this helps,
Ophir

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Hi Ophir,

So do you authenticate with the Web Service API and then use the REST API once you have the token?

The PHP script in the manual is incomplete (i.e. $request[] = ... //Create additional request to the API) Since I don't really know what these requests are supposed to look like I can't actually create one to test. I can remove the line but then it exists silently and I can't even verify that it connected correctly...

I am reading up on JSON but I would still love to see a script that authenticates then maybe retrieves and echos the list of projects or something else equally as generic just so I can verify that I am connecting.

Josh Boutwell 0 votes
Comment actions Permalink
0
Avatar

Hi Josh,
1. No, you don't mix REST & SOAP. The REST API manual discusses authentication for REST API separately.
2. The first sample in the web services documentation is about how to log in. The manual contains more samples about how to create those additional requests, once you have logged in and got your session id.

This forum also contains more samples, particularly with PHP queries with SOAP API (e.g. https://success.clarizen.com/hc/communities/public/questions/203994228-Listing-ONLY-active-projects-with-PHP-and-the-API?locale=en-us). Most of the forum samples are built for version 1.0 of the API, so read the 'New features' section of the web services guide to learn how to migrate them.

It is a matter of taste, but I'd start with the REST API if you use PHP. I find SOAP message construction with PHP unfriendly.
Hope this helps,
Ophir

Ophir Kenig 0 votes
Comment actions Permalink