-
-
Save zackkatz/abcc0a94223b5934fc3cd3fa172418a0 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 = 'https://try.gravityview.co/demo/wp-json/gravityview/v1/views/148/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