{"id":3544,"date":"2022-06-06T08:05:48","date_gmt":"2022-06-06T08:05:48","guid":{"rendered":"https:\/\/blog.ultramsg.com\/esempio-invia-whatsapp-api-con-go-lingua\/"},"modified":"2022-06-06T08:05:49","modified_gmt":"2022-06-06T08:05:49","slug":"esempio-invia-whatsapp-api-con-go-lingua","status":"publish","type":"post","link":"https:\/\/blog.ultramsg.com\/it\/esempio-invia-whatsapp-api-con-go-lingua\/","title":{"rendered":"Come inviare un&#8217;API WhatsApp con Go"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"introduction\">introduzione<\/h2>\n\n<p>In questo tutorial creeremo semplici esempi per inviare messaggi tramite l&#8217;API di WhatsApp utilizzando Go.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"first-whatsapp-api-message-using-go\">Primo messaggio API di WhatsApp utilizzando GO <\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/chat\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;body=WhatsApp API on UltraMsg.com works good&amp;priority=10&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-image\">Invia immagine<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/image\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;image=https:\/\/file-example.s3-accelerate.amazonaws.com\/images\/test.jpg&amp;caption=image Caption&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-document\">Invia documento<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/document\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;filename=hello.pdf&amp;document=https:\/\/file-example.s3-accelerate.amazonaws.com\/documents\/cv.pdf&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-audio\">Invia audio<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/audio\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;audio=https:\/\/file-example.s3-accelerate.amazonaws.com\/audio\/2.mp3&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-voice\">Invia voce<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/voice\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;audio=https:\/\/file-example.s3-accelerate.amazonaws.com\/voice\/oog_example.ogg&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-video\">Invia video<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/video\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;video=https:\/\/file-example.s3-accelerate.amazonaws.com\/video\/test.mp4&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-link\">Invia il link<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/link\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;link=https:\/\/en.wikipedia.org\/wiki\/COVID-19&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-contact\">Invia contatto<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/contact\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;contact=14000000001@c.us&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-location\">Invia posizione<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/location\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;address=ABC company \\n Sixth floor , office 38&amp;lat=25.197197&amp;lng=55.2721877&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-vcard\">Invia Vcard<br\/><\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"golang\" class=\"EnlighterJSRAW\">package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net\/http\"\n\t\"io\/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https:\/\/api.ultramsg.com\/instance1150\/messages\/vcard\"\n\n\tpayload := strings.NewReader(\"token=token_here&amp;to=966550883606&amp;vcard= BEGIN:VCARD\\nVERSION:3.0\\nN:lastname;firstname\\nFN:firstname lastname\\nTEL;TYPE=CELL;waid=14000000001:14000000002\\nNICKNAME:nickname\\nBDAY:01.01.1987\\nX-GENDER:M\\nNOTE:note\\nADR;TYPE=home:;;;;;;\\nADR;TYPE=work_:;;;;;;\\nEND:VCARD&amp;referenceId=\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application\/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}<\/code><\/code><\/pre>\n\n<p>infine, puoi vedere la <a href=\"https:\/\/docs.ultramsg.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">documentazione completa dell&#8217;API di Whatsapp<\/a> e le <a href=\"https:\/\/blog.ultramsg.com\/whatsapp-api-by-ultramsg-faq\/\" data-type=\"URL\" data-id=\"https:\/\/blog.ultramsg.com\/whatsapp-api-by-ultramsg-faq\/\">domande frequenti<\/a> .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>introduzione In questo tutorial creeremo semplici esempi per inviare messaggi tramite l&#8217;API di WhatsApp utilizzando &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Come inviare un&#8217;API WhatsApp con Go\" class=\"read-more button\" href=\"https:\/\/blog.ultramsg.com\/it\/esempio-invia-whatsapp-api-con-go-lingua\/#more-3544\" aria-label=\"Per saperne di pi\u00f9 su Come inviare un&#8217;API WhatsApp con Go\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":3439,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[274],"tags":[293,275,277],"class_list":["post-3544","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api-di-whatsapp","tag-andare","tag-api-di-whatsapp","tag-tutorial-it","infinite-scroll-item","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-25","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/posts\/3544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/comments?post=3544"}],"version-history":[{"count":1,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/posts\/3544\/revisions"}],"predecessor-version":[{"id":3545,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/posts\/3544\/revisions\/3545"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/media\/3439"}],"wp:attachment":[{"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/media?parent=3544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/categories?post=3544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ultramsg.com\/it\/wp-json\/wp\/v2\/tags?post=3544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}