api.php

mail@pastecode.io avatar
unknown
php
a year ago
802 B
3
Indexable
Never
<?php
/* 
 * Template Name: Course Purchased
 */

get_header();
$endpoint = 'http://localhost:8080/gma2/wp-json/jwt-auth/v1/token';

$body = [
    'username'  => 'mariaborsheva',
    'nickname' => 'John Doe',
    'identifier'  => 'mariaborsheva-test2',
    'template'  => 'default',
    'subject'  => 'test',
    'tags'  => ['male'],
];

$body = wp_json_encode( $body );

$options = [
    'body'        => $body,
    'headers'     => [
        'alg' => 'HS256',
        'typ' => 'JWT',
    ],
    'timeout'     => 60,
    'redirection' => 5,
    'blocking'    => true,
    'httpversion' => '1.0',
    'sslverify'   => false,
    'data_format' => 'body',
];

$data = wp_remote_post( $endpoint, $options );
echo "<pre>";
print_r($data);
echo "</pre>";

get_footer();