Planning Center Online PHP API Example

This is some example php code to get you started using the Planning Center API (http://www.planningcenteronline.com/home/api) with php. It handles connecting through oauth, generating the necessary tokens, and making a PUT request to update a person’s data. From here you should be able to build on top of (storing tokens, making other types of PUT, POST, DELETE, and GET requests.) Feel free to fork this.

Overview

common.php

This contains your setup information. It has some configuration information and a common run_curl method.

index.php

This starts off the app. It immediately uses your $key and $secret from Planning Center Online to make the request to the OAuth authorize page – thereby granting access to this little client application.

complete.php

This is the page that Planning Center Online comes back to (assuming you set this correctly when registering a new oauth client application on planningcenteronline.com.)

This file handles trading the keys and secrets around and then makes a put request to update a person’s information using the people api portion of the Planning Center API.

OAuth.php

This is a standard library used by most php programmers for OAuth authentication. It provides some helpers to make the OAuth authorization process easier. It’s available for download here: http://github.com/hugowetterberg/php-oauth-lib

Setting up the app for testing.

Before anything, register your application with Planning Center Online. Contact support@planningcenteronline.com to do so. We’ll send you back a key and a secret that you can use.

  1. Set your key in common.php
  2. Set your secret in common.php
  3. Set your callback url in common.php (this should be the url you want Planning Center to return to after the person has authorized use of your OAuth client application.)
  4. Set $person_id to the id of a person in your people list of your account in complete.php.
  5. Change some parameters for that person’s first name and last name to see that data get updated.
  6. Put the app online to test.
  7. Expand on these basics to build your own client application using Planning Center Online’s data.

Question/Comments

Email support@planningcenteronline.com please.

License

This example code is released under the MIT License.