文档

API 版本 1.1

本文档介绍如何注册、配置和开发您的应用程序,以便您可以成功使用我们的 API

创建应用程序

为了让您的应用程序访问我们的 API,您必须使用注册您的应用程序 应用程序面板. 注册创建一个应用程序 ID,让我们知道您是谁,帮助我们将您的应用程序与其他应用程序区分开来.

  1. 您需要创建一个新的应用程序 创建新应用
  2. 一旦您创建了您的应用程序,您就会得到您的 app_idapp_secret
使用合作商账户登录

使用系统登录是人们创建帐户并登录到您的应用程序的一种快速便捷的方式我们的登录系统支持两个场景,身份验证和请求访问人员数据的权限您可以使用 login with system 简单地进行身份验证,或者同时进行身份验证和数据访问.

  1. 在开始 OAuth 登录过程时,您需要使用应用程序的链接,如下所示:
    <a href="https://www.rubberx.net/api/oauth?app_id=YOUR_APP_ID">Log in With RubberX</a>

    用户将被重定向到这样的页面登录

  2. 一旦用户接受了您的应用程序,用户将被重定向到您的应用程序重定向 URL auth_key 像这样:
    https://mydomain.com/my_redirect_url.php?auth_key=AUTH_KEY
    auth_key 仅对一次性使用有效,因此一旦您使用了它,您将无法再次使用它并生成新代码您需要再次将用户重定向到“登录”链接.
访问令牌

一旦您得到您的应用程序的用户审批,登录窗口并返回 auth_key 这意味着现在您已经准备好从我们的 API 中检索数据,要开始这个过程,您需要授权您的应用程序并获得 access_token 您可以按照我们的步骤学习如何获得它.

  1. 要获取访问令牌,请向以下端点发出 HTTP GET 请求,如下所示:
    <?php
    
    $app_id = "YOUR_APP_ID"; // your app id
    $app_secret = "YOUR_APP_SECRET"; // your app secret
    $auth_key = $_GET['auth_key']; // the returned auth key from previous step
    
    // Prepare the POST data
    $postData = [
      'app_id' => $app_id,
      'app_secret' => $app_secret,
      'auth_key' => $auth_key
    ];
    
    // Initialize cURL
    $ch = curl_init('https://www.rubberx.net/api/authorize');
    
    // Set cURL options for POST
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
    
    // Execute request
    $response = curl_exec($ch);
    
    // Check for cURL errors
    if (curl_errno($ch)) {
      die('cURL error: ' . curl_error($ch));
    }
    
    curl_close($ch);
    
    // Decode the JSON response
    $json = json_decode($response, true);
    
    // Use the access token if available
    if (!empty($json['access_token'])) {
      $access_token = $json['access_token']; // your access token
    }
    ?>
    
    access_token 有效期只有一个 1 小时,所以一旦它变得无效,您将需要通过重定向用户到登录链接再次生成一个新的.
阿皮斯

一旦您得到您的 access_token 现在,您可以通过支持以下参数的 HTTP GET 请求从我们的系统中检索信息

端点 描述
api/get_user_info

获取用户信息

您可以像这样检索用户信息

if(!empty($json['access_token'])) {
    $access_token = $json['access_token']; // your access token
    $get = file_get_contents("https://www.rubberx.net/api/get_user_info?access_token=$access_token");
}

结果将是:

{
  "user_info": {
  "user_id": "",
  "user_name": "",
  "user_email": "",
  "user_firstname": "",
  "user_lastname": "",
  "user_gender": "",
  "user_birthdate": "",
  "user_picture": "",
  "user_cover": "",
  "user_registered": "",
  "user_verified": "",
  "user_relationship": "",
  "user_biography": "",
  "user_website": ""
  }
}
RubberX https://www.rubberx.net