Last active
August 29, 2015 14:12
-
-
Save justingreerbbi/acef7e1a9a1568f153fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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