Skip to content

Instantly share code, notes, and snippets.

@carl-alberto
Last active August 4, 2016 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carl-alberto/d00f33c33373bbba734648bb603f84a5 to your computer and use it in GitHub Desktop.
Save carl-alberto/d00f33c33373bbba734648bb603f84a5 to your computer and use it in GitHub Desktop.
This will connect your WP site to Podio
<?php
/*
* Plugin Name: Podio API
* Version: 1.0
* Plugin URI: http://www.carlalberto.ml/
* Description: This will connect your WP site to Podio
* Author: Carl Alberto
* Author URI: http://www.carlalberto.ml/
* Requires at least: 4.0
* Tested up to: 4.5.2
*
* Text Domain: podio-api
* Domain Path: /lang/
*
* @package WordPress
* @author Carl Alberto
* @since 1.0.0
*/
require_once( 'includes/podio/PodioAPI.php' );
podiorestapi();
function podiorestapi() {
define("CLIENTID","putyour clientID here");
define("CLIENTSECRET","putyour CLIENTSECRET here");
define("APPID","putyour APPID here");
define("APPTOKEN","putyour APPTOKEN here");
Podio::setup(CLIENTID, CLIENTSECRET);
Podio::authenticate_with_app(APPID, APPTOKEN);
add_action( 'rest_api_init', function () {
register_rest_route(
'podio-api/v1', '/connect', array(
'methods' => 'POST',
'callback' => 'podio_connect'
)
);
}
);
}
function podio_connect($data) {
switch ($_POST['type']) {
case 'hook.verify':
PodioHook::validate($_POST['hook_id'], array('code' => $_POST['code']));
case 'item.update':
//reserved for update procedures
case 'item.create':
//reserved for create procedures
case 'item.delete':
//reserved for delete procedures
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment