receivesms.js 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import axios from "axios"
  2. import { createHash } from "crypto"
  3. const account = "account_Rcsgogogo"
  4. const key = "76a44e4d-b960-412d-8624-b66881ad61d6"
  5. function sign(account, key, nonce, timestamp) {
  6. const hash = createHash("sha256")
  7. hash.update(`${account}_${nonce}_${timestamp}_${key}`)
  8. return hash.digest("hex")
  9. }
  10. function getHeader() {
  11. const nonce = '123456'
  12. const timestamp = Date.now()
  13. const signStr = sign(account, key, nonce, timestamp)
  14. console.log({
  15. gatewayId: account,
  16. nonce,
  17. timestamp,
  18. signature: signStr
  19. })
  20. return {
  21. gatewayId: account,
  22. nonce,
  23. timestamp,
  24. sign: signStr
  25. }
  26. }
  27. async function getPhone() {
  28. const { data } = await axios.post(
  29. "http://api.code-sms.net:54722/sms/openApi/phone",
  30. {
  31. country: "USA",
  32. appId: 25
  33. },
  34. {
  35. headers: {
  36. ...getHeader()
  37. }
  38. }
  39. )
  40. console.log(data)
  41. }
  42. getPhone()