如何获取我当前的user_id ..?

时间:2016-07-19 09:18:51

标签: php codeigniter bitcoin coinbase-api

我想使用coinbase api获取用户信息。对于那个我发现了coinbase curl usl,它将为我提供用户信息。

Curl Url:

<?php

$port = 12345;
$server = stream_socket_server("tcp://localhost:$port", $errno, $errstr);
if (!$server) die("$errstr (errno $errno)\n");

$s = array(STDIN, $server); // initially wait for terminal input or connections
while ($r = $s and stream_select($r, $n=NULL, $n=NULL, NULL))
foreach ($r as $stream)
    if ($stream == STDIN)   // terminal input
    {
        $data = fgets(STDIN);
        foreach (array_slice($s, 2) as $client)     // clients from index 2 on
            fputs($client, $data);
    }
    else
    if ($stream == $server) // new client
        $s[] = stream_socket_accept($server, -1);   // add it to $s (index 2 on)
    else                    // data from a client
        if (!fputs(STDOUT, fgets($stream)))
        {
            fclose($stream);
            array_splice($s, array_search($stream, $s), 1); // remove client
        }

?>

我已在coinbase网站注册了我的帐户,也检查了网站提供的所有选项,但没有找到我的user_id。

问题是如何获取我的coinbase帐户的user_id ..?

1 个答案:

答案 0 :(得分:0)

您可以向API询问https://api.coinbase.com/v2/user请求的current User信息。这将返回有关当前用户的任何公开信息。

回复示例:

{
  "data": {
    "id": "9da7a204-544e-5fd1-9a12-61176c5d4cd8",
    "name": "User One",
    "username": "user1",
    "profile_location": null,
    "profile_bio": null,
    "profile_url": "https://coinbase.com/user1",
    "avatar_url": "https://images.coinbase.com/avatar?h=vR%2FY8igBoPwuwGren5JMwvDNGpURAY%2F0nRIOgH%2FY2Qh%2BQ6nomR3qusA%2Bh6o2%0Af9rH&s=128",
    "resource": "user",
    "resource_path": "/v2/user"
  }
}

如您所见,它包含您在id字段下查找的user_id。这应该足以获取您的用户信息。