我的信息

返回当前已认证用户的信息。需要 X-Glue-Authentication 头部。

curl "https://api.hola.cloud/me" \
  -H "X-Glue-Authentication: <token>"
GET /me HTTP/1.1
Host: api.hola.cloud
X-Glue-Authentication: <token>
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.hola.cloud/me", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("X-Glue-Authentication", "<token>")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/me',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        'X-Glue-Authentication: <token>',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "X-Glue-Authentication": "<token>",
}

response = requests.request(
    "GET",
    "https://api.hola.cloud/me",
    headers=headers
)

print(response.text)
const response = await fetch("https://api.hola.cloud/me", {
  method: "GET",
  headers: {
    "X-Glue-Authentication": "<token>"
  }
});

console.log(await response.text());
const response = await fetch("https://api.hola.cloud/me", {
  method: "GET",
  headers: {
    "X-Glue-Authentication": "<token>"
  }
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/me"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .header("X-Glue-Authentication", "<token>")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
 1{
 2  "session": {
 3    "id": "session_123"
 4  },
 5  "user": {
 6    "id": "user_456",
 7    "nick": "johndoe",
 8    "picture": "https://example.com/avatar.png",
 9    "email": "john@example.com"
10  }
11}

评论

发表评论