{"id":2694,"date":"2022-05-03T01:57:18","date_gmt":"2022-05-03T01:57:18","guid":{"rendered":"https:\/\/blog.ultramsg.com\/hantar-whatsapp-message-by-whatsapp-api-using-php\/"},"modified":"2023-03-13T08:58:43","modified_gmt":"2023-03-13T08:58:43","slug":"hantar-whatsapp-message-by-whatsapp-api-using-php","status":"publish","type":"post","link":"https:\/\/blog.ultramsg.com\/ms\/hantar-whatsapp-message-by-whatsapp-api-using-php\/","title":{"rendered":"Cara Menghantar Mesej melalui WhatsApp API menggunakan PHP dengan mudah"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"introduction\">pengenalan<br\/><\/h2>\n\n<p>Dalam tutorial ini, kami akan membuat halaman untuk menghantar mesej melalui API WhatsApp menggunakan PHP<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"installation\">Pemasangan<\/h2>\n\n<p>Muat turun sahaja ultramsg.class.php atau gunakan Komposer:<\/p>\n\n<pre class=\"wp-block-preformatted\"><code data-enlighter-language=\"powershell\" class=\"EnlighterJSRAW\">composer require ultramsg\/whatsapp-php-sdk\n<\/code><div class=\"open_grepper_editor\" title=\"Edit &amp; Save To Grepper\"><div class=\"open_grepper_editor\" title=\"Edit &amp; Save To Grepper\"><\/div><\/div><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"authentication\">Pengesahan<\/h2>\n\n<p><a href=\"https:\/\/user.ultramsg.com\/signup.php\" target=\"_blank\" rel=\"noreferrer noopener\">Daftar<\/a> dan Pergi ke papan pemuka instance anda dan salin ID dan Token Instance anda yang akan digunakan untuk pengesahan.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"example-usage-for-whatsapp-api-using-php\">Contoh penggunaan untuk API WhatsApp menggunakan PHP:<\/h2>\n\n<p>Hantar mesej WhatsApp pertama anda<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">require_once ('vendor\/autoload.php'); \/\/ if you use Composer\n\/\/require_once('ultramsg.class.php'); \/\/ if you download ultramsg.class.php\n\t\n$token=\"tof7lsdJasdloaa57e\"; \/\/ Ultramsg.com token\n$instance_id=\"instance1150\"; \/\/ Ultramsg.com instance id\n$client = new UltraMsg\\WhatsAppApi($token,$instance_id);\n\t\n$to=\"put_your_mobile_number_here\"; \n$body=\"Hello world\"; \n$api=$client-&gt;sendChatMessage($to,$body);\nprint_r($api);<\/code><\/code><\/pre>\n\n<ul class=\"wp-block-list\"><li><strong>$kepada:<\/strong> Nombor WhatsApp penerima dengan format antarabangsa cth, +14155552671 atau chatID untuk kenalan atau kumpulan cth <a href=\"mailto:14155552671@c.us\">14155552671@c.us<\/a> atau <a href=\"mailto:14155552671-441234567890@g.us\">14155552671-441234567890@g.us<\/a><\/li><li><strong>$body<\/strong> : Teks mesej.<\/li><\/ul>\n\n<p><strong>Nota:<\/strong> Anda boleh lihat <a href=\"https:\/\/blog.ultramsg.com\/whatsapp-api-group\/\">di sini<\/a> cara menghantar mesej WhatsApp kepada kumpulan.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"send-image\">Hantar Imej <\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$caption=\"image Caption\"; \n$image=\"https:\/\/file-example.s3-accelerate.amazonaws.com\/images\/test.jpg\"; \n$api=$client->sendImageMessage($to,$image,$caption);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-document\">Hantar Dokumen <\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$filename=\"image Caption\"; \n$document=\"https:\/\/file-example.s3-accelerate.amazonaws.com\/documents\/cv.pdf\"; \n$api=$client-&gt;sendDocumentMessage($to,$filename,$document);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-audio\">Hantar Audio <\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$audio=\"https:\/\/file-example.s3-accelerate.amazonaws.com\/audio\/2.mp3\"; \n$api=$client-&gt;sendAudioMessage($to,$audio);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-voice\">Hantar Suara <\/h2>\n\n<p>Anda boleh Hantar rakaman audio ppt ke nombor telefon atau kumpulan, Tetapi WhatsApp sensitif terhadap sambungan ini, anda perlu berada dalam format OGG dan <strong>codec<\/strong> haruslah <strong>opus<\/strong> , Untuk maklumat lanjut, anda boleh menyemak <a href=\"https:\/\/blog.ultramsg.com\/how-to-send-ogg-file-using-whatsapp-api\/\" data-type=\"URL\" data-id=\"https:\/\/blog.ultramsg.com\/how-to-send-ogg-file-using-whatsapp-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">artikel<\/a> ini.<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$audio=\"https:\/\/file-example.s3-accelerate.amazonaws.com\/voice\/oog_example.ogg\"; \n$api=$client-&gt;sendVoiceMessage($to,$audio);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-video\">Hantar Video <\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$video=\"https:\/\/file-example.s3-accelerate.amazonaws.com\/video\/test.mp4\"; \n$api=$client-&gt;sendVideoMessage($to,$video);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-link\">Hantar Pautan <\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$link=\"https:\/\/ultramsg.com\"; <\/code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$api=$client-&gt;sendLinkMessage($to,$link);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-contact\">Hantar Kenalan<\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$contact=\"14000000001@c.us\"; \n$api=$client-&gt;sendContactMessage($to,$contact);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-location\">Hantar Lokasi<\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$address=\"ABC company \\n Sixth floor , office 38\"; \n$lat=\"25.197197\"; \n$lng=\"55.2721877\"; \n$api=$client-&gt;sendLocationMessage($to,$address,$lat,$lng);\nprint_r($api);<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\" id=\"send-vcard\">Hantar Vcard<\/h2>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">$to=\"put_your_mobile_number_here\"; \n$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\";\n$vcard = preg_replace(\"\/&#91;\\n\\r]\/\", \"\\n\", $vcard);\n$api=$client-&gt;sendVcardMessage($to,$vcard);\nprint_r($api)<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\"><\/h2>\n\n<p>Anda boleh melihat langkah sebelumnya dalam <a href=\"https:\/\/www.youtube.com\/watch?v=OqDOKyMIp20\" data-type=\"URL\" target=\"_blank\" rel=\"noreferrer noopener\">video<\/a> ini dan anda boleh melihat <a href=\"https:\/\/docs.ultramsg.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dokumentasi API WhatsApp<\/a> Penuh.<\/p>\n\n<p><em>Adakah anda menggunakan Ultramsg <a href=\"https:\/\/github.com\/ultramsg\/whatsapp-php-sdk\" target=\"_blank\" rel=\"noopener\">WhatsApp API<\/a> PHP SDK<\/em> ?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pengenalan Dalam tutorial ini, kami akan membuat halaman untuk menghantar mesej melalui API WhatsApp menggunakan &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Cara Menghantar Mesej melalui WhatsApp API menggunakan PHP dengan mudah\" class=\"read-more button\" href=\"https:\/\/blog.ultramsg.com\/ms\/hantar-whatsapp-message-by-whatsapp-api-using-php\/#more-2694\" aria-label=\"Read more about Cara Menghantar Mesej melalui WhatsApp API menggunakan PHP dengan mudah\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":2543,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[245],"tags":[247,246],"class_list":["post-2694","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api-whatsapp-ms","tag-php-ms","tag-tutorial-ms","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\/ms\/wp-json\/wp\/v2\/posts\/2694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/comments?post=2694"}],"version-history":[{"count":10,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/posts\/2694\/revisions"}],"predecessor-version":[{"id":5255,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/posts\/2694\/revisions\/5255"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/media\/2543"}],"wp:attachment":[{"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/media?parent=2694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/categories?post=2694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ms\/wp-json\/wp\/v2\/tags?post=2694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}