riagie/libraries-utils

云数据中心API的库。

0.0.1 2023-04-19 04:04 UTC

This package is auto-updated.

Last update: 2024-09-22 12:14:58 UTC


README

Utils是 Libraries Cloud Data Center 应用程序编程接口(API)的实用工具,允许您访问全球数据服务。

信息结果

测试文件在 tests 目录中

UUID(全球唯一标识符)

生成36位唯一字符串

  • \Libraries\Utils::uuid()
  • 响应
8c4b8c45-befa-4aa1-8313-c8c37b818d4c

密钥

生成32位唯一字符串

  • \Libraries\Utils::secret()
  • 响应
5otdrv7lzspfblf65apnetzn4euvtc6m

引用号(参考号)

生成32位唯一字符串

  • \Libraries\Utils::refnum()
  • 响应
E1JL7J341HGV4LTLRDBWAVMGKVL5XJYO

令牌

生成28位唯一字符串

  • \Libraries\Utils::token()
  • 响应
JvEpqAajNt8VkMRuRnGb34mmwPM7

ID API

生成10位唯一字符串

  • \Libraries\Utils::apiId()
  • 响应
api-2969052206

PPID(个人私有ID)

生成16位随机字母+数字

  • \Libraries\Utils::ppid(string)
  • 参数
**string** "OGIE NURDIANA 081323456789"
  • 响应
OARUENDIIAOGNA57

CID(中央ID)

  • \Libraries\Utils::unique(alfabet, length_number)
  • 参数
**alfabet** string of 1 letter
**length_number** number 1 digit
  • 响应
323545

电话

  • \Libraries\Utils::phoneNumber(number_phone, region_code)
  • 参数
**number_phone** number
**region_code** string
  • 响应
(
    [regionCode] => ID
    [numberType] => Mobile
    [providerNumber] => Telkomsel
    [countryCode] => 62
    [number] => 81323456789
    [possibleNumber] => 1
    [validNumber] => 1
)

开始时间

  • \Libraries\Utils::setStartTime(time_start)
  • 参数
**time_start** microtime(true)
  • 响应
1681805195.8551

已过时间

  • \Libraries\Utils::getElapsedTime($time_start)
  • 参数
**time_start** from setStartTime
  • 响应
1.5020370483398E-5

过期

  • \Libraries\Utils::setExpired(number)
  • 参数
**number** number in count day
  • 响应
2023-04-19

Curl头部

  • \Libraries\Utils::setHeaders(curl, headers, time)
  • 参数
**curl** new \Curl\Curl()
**headers** array key header and value
**time** interval /sec 
  • 响应
(
    [curl] => Resource id #106
    [id] => 643e4f8bd20ef3.43049570
    [error] => 
    [errorCode] => 0
    [errorMessage] => 
    [curlError] => 
    [curlErrorCode] => 0
    [curlErrorMessage] => 
    [httpError] => 
    [httpStatusCode] => 0
    [httpErrorMessage] => 
    [url] => 
    [requestHeaders] => Array
        (
        )

    [responseHeaders] => 
    [rawResponseHeaders] => 
    [responseCookies] => Array
        (
        )

    [response] => 
    [rawResponse] => 
    [downloadCompleteCallback] => 
    [fileHandle] => 
    [downloadFileName] => 
    [attempts] => 0
    [retries] => 0
    [childOfMultiCurl] => 
    [remainingRetries] => 0
    [retryDecider] => 
    [jsonDecoder] => 
    [xmlDecoder] => 
    [headerCallbackData:Curl\Curl:private] => stdClass Object
        (
            [rawResponseHeaders] => 
            [responseCookies] => Array
                (
                )

            [stopRequestDecider] => 
            [stopRequest] => 
        )

    [cookies:Curl\Curl:private] => Array
        (
        )

    [headers:Curl\Curl:private] => Curl\CaseInsensitiveArray Object
        (
            [data:Curl\CaseInsensitiveArray:private] => Array
                (
                    [content-type] => application/x-www-form-urlencoded
                    [cache-control] => private, max-age=30
                    [expires] => Tue, 18 Apr 2023 08:07:05 GMT
                    [accept-encoding] => gzip, deflate, br
                )

            [keys:Curl\CaseInsensitiveArray:private] => Array
                (
                    [content-type] => Content-Type
                    [cache-control] => Cache-Control
                    [expires] => Expires
                    [accept-encoding] => Accept-Encoding
                )

        )

    [jsonDecoderArgs:Curl\Curl:private] => Array
        (
        )

    [jsonPattern:Curl\Curl:private] => /^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i
    [xmlDecoderArgs:Curl\Curl:private] => Array
        (
        )

    [xmlPattern:Curl\Curl:private] => ~^(?:text/|application/(?:atom\+|rss\+|soap\+)?)xml~i
    [defaultDecoder:Curl\Curl:private] => 
    [beforeSendCallback] => 
    [successCallback] => 
    [errorCallback] => 
    [completeCallback] => 
    [options:protected] => Array
        (
            [181] => 3
            [182] => 3
            [10018] => Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0
            [13] => 30
            [2] => 1
            [20056] => Closure Object
                (
                    [static] => Array
                        (
                            [header_callback_data] => stdClass Object
                                (
                                    [rawResponseHeaders] => 
                                    [responseCookies] => Array
                                        (
                                        )

                                    [stopRequestDecider] => 
                                    [stopRequest] => 
                                )

                        )

                    [parameter] => Array
                        (
                            [$resource] => <required>
                            [$download_size] => <required>
                            [$downloaded] => <required>
                            [$upload_size] => <required>
                            [$uploaded] => <required>
                        )

                )

            [43] => 
            [20079] => Closure Object
                (
                    [static] => Array
                        (
                            [header_callback_data] => stdClass Object
                                (
                                    [rawResponseHeaders] => 
                                    [responseCookies] => Array
                                        (
                                        )

                                    [stopRequestDecider] => 
                                    [stopRequest] => 
                                )

                        )

                    [parameter] => Array
                        (
                            [$ch] => <required>
                            [$header] => <required>
                        )

                )

            [19913] => 1
            [10023] => Array
                (
                    [0] => Content-Type: application/x-www-form-urlencoded
                    [1] => Cache-Control: private, max-age=30
                    [2] => Expires: Tue, 18 Apr 2023 08:07:05 GMT
                    [3] => Accept-Encoding: gzip, deflate, br
                )

        )

)

Curl选项

  • \Libraries\Utils::setOpts(curl, opts) $setOpts["CURLOPT_ENCODING"] = "gzip, deflate, br"
  • 参数
**curl** new \Curl\Curl()
**opts** array key Opts and value
  • 响应
(
    [curl] => Resource id #106
    [id] => 643e4f8bd20ef3.43049570
    [error] => 
    [errorCode] => 0
    [errorMessage] => 
    [curlError] => 
    [curlErrorCode] => 0
    [curlErrorMessage] => 
    [httpError] => 
    [httpStatusCode] => 0
    [httpErrorMessage] => 
    [url] => 
    [requestHeaders] => Array
        (
        )

    [responseHeaders] => 
    [rawResponseHeaders] => 
    [responseCookies] => Array
        (
        )

    [response] => 
    [rawResponse] => 
    [downloadCompleteCallback] => 
    [fileHandle] => 
    [downloadFileName] => 
    [attempts] => 0
    [retries] => 0
    [childOfMultiCurl] => 
    [remainingRetries] => 0
    [retryDecider] => 
    [jsonDecoder] => 
    [xmlDecoder] => 
    [headerCallbackData:Curl\Curl:private] => stdClass Object
        (
            [rawResponseHeaders] => 
            [responseCookies] => Array
                (
                )

            [stopRequestDecider] => 
            [stopRequest] => 
        )

    [cookies:Curl\Curl:private] => Array
        (
        )

    [headers:Curl\Curl:private] => Curl\CaseInsensitiveArray Object
        (
            [data:Curl\CaseInsensitiveArray:private] => Array
                (
                    [content-type] => application/x-www-form-urlencoded
                    [cache-control] => private, max-age=30
                    [expires] => Tue, 18 Apr 2023 08:07:05 GMT
                    [accept-encoding] => gzip, deflate, br
                )

            [keys:Curl\CaseInsensitiveArray:private] => Array
                (
                    [content-type] => Content-Type
                    [cache-control] => Cache-Control
                    [expires] => Expires
                    [accept-encoding] => Accept-Encoding
                )

        )

    [jsonDecoderArgs:Curl\Curl:private] => Array
        (
        )

    [jsonPattern:Curl\Curl:private] => /^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i
    [xmlDecoderArgs:Curl\Curl:private] => Array
        (
        )

    [xmlPattern:Curl\Curl:private] => ~^(?:text/|application/(?:atom\+|rss\+|soap\+)?)xml~i
    [defaultDecoder:Curl\Curl:private] => 
    [beforeSendCallback] => 
    [successCallback] => 
    [errorCallback] => 
    [completeCallback] => 
    [options:protected] => Array
        (
            [181] => 3
            [182] => 3
            [10018] => Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0
            [13] => 30
            [2] => 1
            [20056] => Closure Object
                (
                    [static] => Array
                        (
                            [header_callback_data] => stdClass Object
                                (
                                    [rawResponseHeaders] => 
                                    [responseCookies] => Array
                                        (
                                        )

                                    [stopRequestDecider] => 
                                    [stopRequest] => 
                                )

                        )

                    [parameter] => Array
                        (
                            [$resource] => <required>
                            [$download_size] => <required>
                            [$downloaded] => <required>
                            [$upload_size] => <required>
                            [$uploaded] => <required>
                        )

                )

            [43] => 
            [20079] => Closure Object
                (
                    [static] => Array
                        (
                            [header_callback_data] => stdClass Object
                                (
                                    [rawResponseHeaders] => 
                                    [responseCookies] => Array
                                        (
                                        )

                                    [stopRequestDecider] => 
                                    [stopRequest] => 
                                )

                        )

                    [parameter] => Array
                        (
                            [$ch] => <required>
                            [$header] => <required>
                        )

                )

            [19913] => 1
            [10023] => Array
                (
                    [0] => Content-Type: application/x-www-form-urlencoded
                    [1] => Cache-Control: private, max-age=30
                    [2] => Expires: Tue, 18 Apr 2023 08:07:05 GMT
                    [3] => Accept-Encoding: gzip, deflate, br
                )

            [52] => 1
            [10102] => gzip, deflate, br
            [68] => 10
            [84] => CURL_HTTP_VERSION_1_1
            [42] => 
            [64] => 
            [81] => 
            [45] => 
            [41] => 
            [10082] => logs/20230418-cookie.txt
            [10031] => logs/20230418-cookie.txt
            [78] => 60
        )

)

加载文件

  • \Libraries\Utils::loadFile(directory)
  • 参数
**directory** directory file and name file
  • 响应
## Libraries
Utils application programming interfaces (API's) that enables you to access data globally service. 
After you register your app and get authentication tokens for a user or service, you can make requests to the Cloud Data Center API's.1

环境

  • \Libraries\Utils::getEnv()
  • 响应
(
    [ALLUSERSPROFILE] => C:\ProgramData
    [APPDATA] => C:\Users\{{users}}\AppData\Roaming
    [CHROME_CRASHPAD_PIPE_NAME] => \\.\pipe\LOCAL\crashpad_14404_SRPQTVJZEXRLOIIE
    [CommonProgramFiles] => C:\Program Files\Common Files
    [CommonProgramFiles(x86)] => C:\Program Files (x86)\Common Files
    [CommonProgramW6432] => C:\Program Files\Common Files
    [COMPUTERNAME] => 9F079636H
    [ComSpec] => C:\Windows\system32\cmd.exe
    [DriverData] => C:\Windows\System32\Drivers\DriverData
    [ESET_OPTIONS] =>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    [FPS_BROWSER_APP_PROFILE_STRING] => Internet Explorer
    [FPS_BROWSER_USER_PROFILE_STRING] => Default
    [HOMEDRIVE] => C:
    [HOMEPATH] => \Users\{{users}}
    [LOCALAPPDATA] => C:\Users\{{users}}\AppData\Local
    [LOGONSERVER] => \\9F079636H
    [NUMBER_OF_PROCESSORS] => 4
    [OneDrive] => C:\Users\{{users}}\OneDrive
    [OneDriveConsumer] => C:\Users\{{users}}\OneDrive
    [ORIGINAL_XDG_CURRENT_DESKTOP] => undefined
    [OS] => Windows_NT
    [Path] => C:\Program Files\Java\jdk\bin;C:\Program Files\Java\jre\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Composer;C:\xampp\mysql\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\xampp\php-739;C:\xampp\MongoDB\Server\6.0\bin;C:\Program Files\apache-jmeter-5.5\bin;C:\xampp\nginx;C:\Users\{{users}}\AppData\Local\Microsoft\WindowsApps;C:\Users\{{users}}\AppData\Roaming\Composer\vendor\bin
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    [PROCESSOR_ARCHITECTURE] => AMD64
    [PROCESSOR_IDENTIFIER] => Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
    [PROCESSOR_LEVEL] => 6
    [PROCESSOR_REVISION] => 3d04
    [ProgramData] => C:\ProgramData
    [ProgramFiles] => C:\Program Files
    [ProgramFiles(x86)] => C:\Program Files (x86)
    [ProgramW6432] => C:\Program Files
    [PSModulePath] => C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
    [PUBLIC] => C:\Users\Public
    [SESSIONNAME] => Console
    [SystemDrive] => C:
    [SystemRoot] => C:\Windows
    [TEMP] => C:\Users\OGIENU~1\AppData\Local\Temp
    [TMP] => C:\Users\OGIENU~1\AppData\Local\Temp
    [USERDOMAIN] => 9F079636H
    [USERDOMAIN_ROAMINGPROFILE] => 9F079636H
    [USERNAME] => {{users}}
    [USERPROFILE] => C:\Users\{{users}}
    [VSCODE_AMD_ENTRYPOINT] => vs/workbench/api/node/extensionHostProcess
    [VSCODE_CODE_CACHE_PATH] => C:\Users\{{users}}\AppData\Roaming\Code\CachedData\704ed70d4fd1c6bd6342c436f1ede30d1cff4710
    [VSCODE_CRASH_REPORTER_PROCESS_TYPE] => extensionHost
    [VSCODE_CRASH_REPORTER_SANDBOXED_HINT] => 1
    [VSCODE_CWD] => C:\Program Files\Microsoft VS Code
    [VSCODE_HANDLES_UNCAUGHT_ERRORS] => true
    [VSCODE_IPC_HOOK] => \\.\pipe\28bce457577a9dfc47e72f5601a35cdb-1.77.3-main-sock
    [VSCODE_L10N_BUNDLE_LOCATION] => 
    [VSCODE_NLS_CONFIG] => {"locale":"en-us","osLocale":"en-us","availableLanguages":{},"_languagePackSupport":true}
    [VSCODE_PID] => 14404
    [windir] => C:\Windows
    [XDEBUG_CONFIG] => client_port=57245
    [XDEBUG_MODE] => debug,develop
)

浏览器

  • \Libraries\Utils::clientBrowser()
  • 响应
(
    [userAgent] => 
    [browserName] => unknown
    [browserVer] => unknown
    [platformFamily] => unknown
    [platformVer] => unknown
    [platformName] => unknown
    [platformIs64bit] => 
    [isMobile] => 
    [isRobot] => 
    [isInIECompat] => 
    [strEmulatedIE] => 
    [arrayEmulatedIE] => Array
        (
            [browser] => 
            [version] => 
        )

    [isChromeFrame] => 
)

IP

  • \Libraries\Utils::clientIp()
  • 响应
UNKNOWN

地理位置

  • \Libraries\Utils::geolocation(ip)
  • 参数
**ip** public IP is opsional
  • 响应
(
    [status] => success
    [continent] => Asia
    [continentCode] => AS
    [country] => Indonesia
    [countryCode] => ID
    [region] => JB
    [regionName] => West Java
    [city] => Bandung
    [district] => 
    [zip] => 
    [lat] => -6.9217
    [lon] => 107.6071
    [timezone] => Asia/Jakarta
    [offset] => 25200
    [currency] => IDR
    [isp] => PT. TELKOM INDONESIA
    [org] => 
    [as] => AS7713 PT Telekomunikasi Indonesia
    [asname] => telkomnet-as-ap
    [reverse] => 
    [mobile] => 
    [proxy] => 
    [hosting] => 
    [query] => 180.244.129.23
)

数据库

  • \Libraries\Utils::database(name, config)
  • 参数
**name** name class
**config** accses database in array example `array ("API_CENTRAL", "127.0.0.1", 3306, "root", "root")`
  • 响应
(
    [scalar] => Class DBMySQL not found
)

转换对象

  • \Libraries\Utils::Object(object)
  • 参数
**object** data object
  • 响应
(
    [opacity] => 0.5
    [index] => Array
        (
            [0] => white
            [1] => black
        )

    [colors] => stdClass Object
        (
            [index] => Array
                (
                    [0] => White
                    [1] => Black
                    [2] => Red
                    [3] => Green
                    [4] => Blue
                )

        )

    [red] => stdClass Object
        (
            [r] => ff
            [g] => 00
            [b] => 00
        )

    [green] => stdClass Object
        (
            [r] => 00
            [g] => ff
            [b] => 00
        )

    [blue] => stdClass Object
        (
            [r] => 00
            [g] => 00
            [b] => ff
        )

)

转换JSON

  • \Libraries\Utils::Json(type, data)
  • 参数
**type** request format
**data** data array
  • 响应
(
    [scalar] => {"red":"ff0000","green":"00ff00","blue":"0000ff"}
)

将数组转换为XML

  • \Libraries\Utils::Xml(data, encoding, version, standalone)
  • 参数
**data** data array
**encoding** format encoding is optional
**version** version xml is optional
**standalone** active standalone or not is optional
  • 响应
<?xml version="1.1" encoding="UTF-8" standalone="yes"?>
<root><Good_guy><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name>Sauron</name><weapon>Evil Eye</weapon></Bad_guy></root>

将数组转换为文本

  • \Libraries\Utils::Text(header, massage)
  • 参数
**header** array head
**massage** array data
  • 响应
DARK_RED|LIGHT_GREEN|BLUE
01|11|21
02|12|22
03|13|23