简体   繁体   English

在简单的 JavaScript 中从 textarea 内容发送推文并发送到 WhatsApp

[英]Tweet and send to WhatsApp from textarea content in simple JavaScript

Need a help in tweeting and sending to Whatsapp from textarea content in Simple JavaScript.需要帮助从 Simple JavaScript 中的 textarea 内容发送推文和发送到 Whatsapp。 Is there any workaround?有什么解决方法吗?

Here is the Code example for sharing it on Whatsapp.这是在 Whatsapp 上共享的代码示例。 : JS: : JS:

function new_share()
{
    var whatsapp_content = document.getElementById("myInput").value;
    if(whatsapp_content!=='')
    {
       whatsapp_link = 'via Editor  ';

      var url = "https://web.whatsapp.com/send?text="+ whatsapp_content + whatsapp_link;
      document.getElementById('whatsapp_link').setAttribute("href",url);
     }
} 

HTML: HTML:

Textarea id: myInput文本区域 ID:myInput

<a id="whatsapp_link" rel="nofollow noopener" target="_blank" onclick="new_share()">Share on WhatsApp

I tried, with tweet button provided by twitter.我试过了,用 twitter 提供的推特按钮。 It is not working.它不工作。

Example for Tweet:推文示例:

<a class="twitter-share-button" href="https://twitter.com/intent/tweet?text=Hello%20world">Tweet</a>

You can try to send a request to Twitter API, but you need to put your request in the backend to hide your credentials.您可以尝试向 Twitter API 发送请求,但您需要将请求放在后端以隐藏您的凭据。

You can see the Twitter API doc:您可以查看 Twitter API 文档:

https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM