Skip to content

Instantly share code, notes, and snippets.

@tomharrigan
Last active February 7, 2017 15:36
Show Gist options
  • Save tomharrigan/9f515b56dff3865a42945172bc66052c to your computer and use it in GitHub Desktop.
Save tomharrigan/9f515b56dff3865a42945172bc66052c to your computer and use it in GitHub Desktop.
Testing purposes only. NOT suitable for production
public function alexawp_news_request( WP_REST_Request $request ) {
$body = $this->access_protected( $request, 'body' );
//if ( ! empty( $body ) ) {
try {
//$alexa_settings = get_option( 'alexawp-settings' );
//$app_id = $alexa_settings['news_id'];
//$certificate = new \Alexa\Request\Certificate( $request->get_header( 'signaturecertchainurl' ), $request->get_header( 'signature' ), $app_id );
$alexa = new \Alexa\Request\IntentRequest( $body, $app_id );
//$alexa->setCertificateDependency( $certificate );
// Parse and validate the request.
$alexa_request = $alexa->fromData();
} catch ( InvalidArgumentException $e ) {
return $this->fail_response( $e );
}
$response = new \Alexa\Response\Response;
$event = new AlexaEvent( $alexa_request, $response );
$news = new Alexa_News();
$news->news_request( $event );
return new WP_REST_Response( $response->render() );
//}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment