📜 ⬆️ ⬇️

Twitter use non-standard

Twitter is a well-known service, it provides the infrastructure for exchanging short text messages, searching, tagging, etc.

But this is exactly what most small data services need. In my case, this is the editor of riffs (short tunes):

image

All we need is to add a button for Tweet a piece of data (in this example, these are notes of melolody) with id = "twitButton":
')
<a id="twitButton" class="twitter-share-button">Tweet</a> 

initialize it:

 document.getElementById("twitButton").href="https://twitter.com/intent/tweet?text=#riffshare&url=https://surikov.imtqy.com/riffshare/parse.html%3Friff%3D"+encoded; 

and initialize the Twitter library:

 window.twttr=(function(d,s,id){ var js ,fjs=d.getElementsByTagName(s)[0] ,t=window.twttr||{}; if(d.getElementById(id))return; js=d.createElement(s); js.id=id; js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js,fjs); t._e=[]; t.ready=function(f){ t._e.push(f); }; return t; } (document,"script","twitter-wjs") ); 

The created button publishes a regular tweet with a link to the service and the advanced encoded parameter (with notes), with Twitter automatically using its own link shortening service and the URL is compressed to the allowed length of the tweet.

Tweets can be edited, deleted, added tags and retweeted like any regular posts. Clicking the link opens the pages of the music editor and the text from the variable in the URL is parsed with regular Javascript.

Link example in tweet


https://t.co/rnwcSBUQ6P - a Christmas tree was born in the forest.

Total


This method of data exchange is not suitable for everyone, but in some cases it may be useful.

Source: https://habr.com/ru/post/318822/


All Articles