Skip to content

Instantly share code, notes, and snippets.

@justingreerbbi
Last active August 29, 2015 14:12
Show Gist options
  • Save justingreerbbi/acef7e1a9a1568f153fe to your computer and use it in GitHub Desktop.
Save justingreerbbi/acef7e1a9a1568f153fe to your computer and use it in GitHub Desktop.
<?php
/**
* Add a new endpoint and functionality to WordPress OAuth Server.
* This snippet would go in your functions file.
*
* Requires that WP OAuth Server installed and activated.
* It can access using a valide access_token.
*
* POST/GET - Return JSON
* /oauth/hello?access_token=1234
*
* @author Justin Greer <justin@justin-greer.com>
*/
add_filter('wo_endpoints','new_hello_endpoint', 2);
function new_hello_endpoint ($methods)
{
$methods['hello'] = array('func'=>'run_hello_method');
return $methods;
}
function run_hello_method ($token)
{
$response = new OAuth2\Response(array('say'=>'hello'));
$response->send();
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment