使用CURL PHP将令牌ID从一个API传递到另一个API

时间:2018-08-13 09:18:34

标签: php php-curl

我有一个客户端API,其中第一个API是loginAPI URL,它将在触发令牌ID时生成,并且仅会激活20分钟,并且令牌ID必须传入主API URL中。在标题中。 20分钟后,loginAPI网址必须再次触发才能每次获取新的令牌ID。

所以我是这类问题的新手,所以任何人都可以帮我提出想法/建议来运行API。

1 个答案:

答案 0 :(得分:0)

@Ritesh:请按照以下步骤

  1. 在系统中的设备表上创建,您可以在该表中管理用户ID,设备ID和令牌ID,令牌时间。

  2. 调用主api时,令牌时间将使用相应的令牌ID进行更新

  3. 匹配当前时间和令牌更新时间。如果时间间隔大于20分钟,则更新令牌ID

    REPORT ztest.
    
    TYPES:
      BEGIN OF ts_input,
        so            TYPE char3,
        customer      TYPE char5,
        materialno    TYPE i,
        materialgroup TYPE char6,
        liters        TYPE i,
      END OF ts_input,
    
      BEGIN OF ts_output,
        so            TYPE char3,
        customer      TYPE char5,
        materialgroup TYPE char6,
        liters        TYPE i,
      END OF ts_output.
    
    DATA:
      lv_liters TYPE i,
    
      gt_input  TYPE STANDARD TABLE OF ts_input,
      gs_input  TYPE ts_input,
      gt_temp   TYPE STANDARD TABLE OF ts_output,
      gs_temp   TYPE ts_output,
      gt_output TYPE STANDARD TABLE OF ts_output,
      gs_output TYPE ts_output.
    
    START-OF-SELECTION.
      gs_input-so            = '001'.
      gs_input-customer      = 'james'.
      gs_input-materialno    = 1.
      gs_input-materialgroup = 'GroupA'.
      gs_input-liters        = 5.
      APPEND gs_input TO gt_input.
      gs_input-so            = '001'.
      gs_input-customer      = 'james'.
      gs_input-materialno    = 2.
      gs_input-materialgroup = 'GroupA'.
      gs_input-liters        = 10.
      APPEND gs_input TO gt_input.
      gs_input-so            = '001'.
      gs_input-customer      = 'james'.
      gs_input-materialno    = 3.
      gs_input-materialgroup = 'GroupB'.
      gs_input-liters        = 20.
      APPEND gs_input TO gt_input.
    
      gs_input-so            = '002'.
      gs_input-customer      = 'john'.
      gs_input-materialno    = 2.
      gs_input-materialgroup = 'GroupA'.
      gs_input-liters        = 10.
      APPEND gs_input TO gt_input.
      gs_input-so            = '002'.
      gs_input-customer      = 'john'.
      gs_input-materialno    = 3.
      gs_input-materialgroup = 'GroupA'.
      gs_input-liters        = 10.
      APPEND gs_input TO gt_input.
      gs_input-so            = '002'.
      gs_input-customer      = 'john'.
      gs_input-materialno    = 4.
      gs_input-materialgroup = 'GroupB'.
      gs_input-liters        = 20.
      APPEND gs_input TO gt_input.
      gs_input-so            = '002'.
      gs_input-customer      = 'john'.
      gs_input-materialno    = 5.
      gs_input-materialgroup = 'GroupB'.
      gs_input-liters        = 5.
      APPEND gs_input TO gt_input.
    
      " move to temp. table, skip MaterialNo
      LOOP AT gt_input INTO gs_input.
        gs_temp-so            = gs_input-so.
        gs_temp-customer      = gs_input-customer.
        gs_temp-materialgroup = gs_input-materialgroup.
        gs_temp-liters        = gs_input-liters.
        APPEND gs_temp TO gt_temp.
      ENDLOOP.
    
    
      SORT gt_temp ASCENDING BY so customer materialgroup.
    
      LOOP AT gt_temp INTO gs_temp.
        AT NEW materialgroup.
          CLEAR lv_liters.
        ENDAT.
    
        lv_liters = lv_liters + gs_temp-liters.
    
        AT END OF materialgroup.
          gs_output-so            = gs_temp-so.
          gs_output-customer      = gs_temp-customer.
          gs_output-materialgroup = gs_temp-materialgroup.
          gs_output-liters        = lv_liters.
          APPEND gs_output TO gt_output.
        ENDAT.
    
      ENDLOOP.

以下是表架构 http://prntscr.com/khz8wz