Edits history of script submission #22803 for ' List Phone Numbers (whatsapp_business)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Phone Numbers
     * List the phone numbers registered on the WhatsApp Business Account, with their verification status and quality rating.
     */
    export async function main(auth: RT.WhatsappBusiness) {
      const apiVersion = auth.api_version || "v25.0"
      const url = new URL(
        `https://graph.facebook.com/${apiVersion}/${auth.business_account_id}/phone_numbers`
      )
      url.searchParams.append(
        "fields",
        "id,display_phone_number,verified_name,code_verification_status,quality_rating,platform_type"
      )
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 hours ago