Yes, I read out the API documentation but there are no clear examples of how to use it and searched online for examples but nothing was found.
Please, give some examples
What I need is
1. check the user if exists if not return a message ‘no account founds’
2. Display the current balance
function wpb_api(){
$current_user = wp_get_current_user();
$mail = $current_user->user_email;
$secret_key = '*****kjmsJvT';
$remote_url = 'https://example.com/api-dev/';
$action = 'GET';
$account = '$mail';
$point_type = 'mycred_default';
$host = get_bloginfo( 'url' );
$token = md5( $host . $action . $secret_key );
$request = array(
'method' => 'POST',
'body' => array(
'action' => $action,
'account' => $account,
'type' => $point_type,
'token' => $token,
'host' => $host
)
);
$response = wp_remote_post( $remote_url, $request );
$balance_html = wp_remote_retrieve_body( $response );
echo $balance_html;
}
add_shortcode('api-test','wpb_api');
This shortcode returns the current user balance. This shortcode is correct to use or not and how to return the message (check the user if exists if not return a message ‘no account founds’)