WhatsApp Number Verification
WhatsApp Number Verification
In[]:=
Now
Out[]=
$appID="your-app-id";
$appSecret="your-app-secret"
$certificate="your-certificate";
$phoneNumberID="your-phone-number-id";$wabaID="your-waba-id";
$permanentToken="your-permanent-token";
◼
Get numbers
In[]:=
$wabaNumbers=URLRead[URLBuild[{"https://graph.facebook.com/v24.0/",$wabaID,"phone_numbers"},{"access_token"->$permanentToken}]]
◼
Validate certificate
$registrationResponse=URLRead[HTTPRequest[URLBuild[{"https://graph.facebook.com/v24.0/",$phoneNumberID,"register"}],<|Method->"POST","Body"->ExportString[<|"messaging_product"->"whatsapp","certificate"->$certificate,"pin"->420420|>,"JSON"],"Headers"-><|"Authorization"->StringJoin[{"Bearer ",$permanentToken}],"Content-Type"->"application/json"|>|>]]
In[]:=
$registrationResponse["Body"]
Out[]=
{"success":true}
◼
Subscribe you app
So webhooks work
In[]:=
$subscribeApp=URLRead[HTTPRequest[URLBuild[{"https://graph.facebook.com/v24.0/",$wabaID,"subscribed_apps"}],<|Method->"POST","Headers"-><|"Authorization"->StringJoin[{"Bearer ",$permanentToken}],"Content-Type"->"application/json"|>,"Body"->ExportString[<|"subscribed_fields"->{"messages"}|>,"JSON"]|>]]
$subscribeApp["Body"]
Out[]=
{"success":true}