跳至主要內容
iRoamly Shop

查詢 QR Code(Python)

查詢 QR Code 的完整 Python 請求,包含 AuthKey 與 Certification 標頭。請將預留的 AuthKey 與 AuthSecret 替換為您 API 金鑰頁面上的值。

程式碼參考

查詢 QR Code(Python)

python
import requests
import json
import hashlib

# URL for the request
url = "https://api.iroamly.shop/openapi/qrcodeQuery"

# Provided AuthKey and AuthSecret, remember to replace them with real values
auth_key = "YOUR_AUTH_KEY_HERE"
auth_secret = "YOUR_AUTH_SECRET_HERE" 


# Calculating Certification
combined = auth_key + auth_secret
certification = hashlib.sha256(combined.encode()).hexdigest()

# Header parameters for the request
headers = {
    "Content-Type": "application/json",
    "AuthKey": auth_key,
    "Certification": certification
}

# Example data for the request body
data = {
    "redeemCode":"XRdDeSxBVNbvCpU"
}

# Sending POST request
response = requests.post(url, headers=headers, data=json.dumps(data))

# Printing the response content
print(response.text)

# Example of response
{
 "code":1,
 "qrcode":"https:/code.tokyoesim.com/20231220/1703048857317.65625d0a779f4598d55d77bda43ecd80.png",
 "msg":"success",
 "redeemCode":"XRdDeSxBVNbvCpU"
}
API 端點

查詢 QR Code

請求 URL:https://api.iroamly.shop/openapi/qrcodeQuery
請求方法:POST

請求參數:

參數說明類型
redeemCode兌換碼String

回應欄位說明:

欄位說明類型
redeemCode兌換碼String
qrcodeQR Code 圖片 URLString
status兌換碼狀態(請參閱「兌換碼狀態定義」)Int
qrcode_contentQR Code 內容(LPA 啟用字串,例如 LPA:1$…)String
iscouldrenewaleSIM 是否可續約: 1 - 可續約 0 - 不可續約Int
參數範例
{
  "redeemCode": "m8hed7h2fed",
}
回傳範例
{
  "code": 1,
  "msg": "success",
  "redeemCode": "m8hed7h2fed",
  "qrcode": "https://dsfjigewafe/qrcode.jpg"
}
程式碼參考

更多 Python 範例