Created
July 9, 2018 21:07
-
-
Save rafaehlers/1761bdaa4b36928c0e034e666f5c65de to your computer and use it in GitHub Desktop.
Code snippet for this: https://docs.gravityview.co/article/468-rest-api (Authentication section)
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 | |
$entries_url = 'http://gv2.dev.codeseekah.com/wp-json/gravityview/v1/views/1696/entries.json'; | |
$nonce = wp_create_nonce( 'wp_rest' ); | |
?> | |
<script type="text/javascript"> | |
jQuery.ajax( { | |
url: <?php echo json_encode( $entries_url ); ?>, | |
method: 'GET', | |
beforeSend: function ( xhr ) { | |
xhr.setRequestHeader( 'X-WP-Nonce', <?php echo json_encode( $nonce ); ?> ); | |
}, | |
} ).done( function ( response ) { | |
console.log( response ); | |
} ); | |
</script> | |
<?php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment