problem using javascript and sending hashtag

%3CLINGO-SUB%20id%3D%22lingo-sub-3221463%22%20slang%3D%22en-US%22%3Eproblem%20using%20javascript%20and%20sending%20hashtag%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3221463%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20big%20problem%20I%20even%20don't%20know%20where%20to%20begin%20because%20my%20code%20is%20in%20Java%20and%20I%20need%20to%20use%20HTML%20tags%20too.%20So%20the%20data%20I'm%20using%20is%20mostly%20numbers%20within%20tables%20in%20the%20webpage%20and%20I%20want%20to%20use%20a%20specific%20tag%20in%20my%20code%20via%20a%20result%20of%20a%20row%20that%20meets%20a%20column%20(like%20Excel).%20I%20also%20have%20another%20problem%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CP%3EI'm%20trying%20to%20'post'%20the%20%23%20sign%20to%20make%20some%20words%20turn%20to%20hashtags%20in%20the%20target%20url%20but%20the%20code%20doesn't%20work%20and%20it's%20via%20API%20using%20this%20code%3A%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3Etrue%20%3D%3D%20function()%0A%7B%0Avar%20getMyItem%20%3D%20function%20(str)%0A%7B%0Aif%20(sessionStorage.getItem(str)%20%3D%3D%20null)%0A%7B%0AsetMyItem(str%2C%200)%3B%0Areturn%200%3B%0A%7D%0Areturn%20sessionStorage.getItem(str)%3B%0A%7D%0Avar%20setMyItem%20%3D%20function%20(key%2C%20value)%0A%7B%0AsessionStorage.setItem(key%2C%20value)%3B%0A%7D%0A%0Afunction%20bot(post)%0A%7B%0Aconst%20Http%20%3D%20new%20XMLHttpRequest()%3B%0Avar%20Token%3D%22xxxxxxxxxxxxxxxxxxxxxxxxxxxxx%22%3B%20%2F%2F%20Token%0Avar%20ID%3D%20%22xxxxxx%22%3B%0Avar%20url%3D%20'https%3A%2F%2Fbot.xxx%2Fapi%2F'%2BToken%2B'%2FsendMessage%3Ftext%3D'%2Bpost%2B'%26amp%3Bchat_id%3D'%2BID%3B%0AHttp.open(%22GET%22%2C%20url)%3B%0AHttp.send()%3B%0A%7D%0A%2F%2F%20you%20need%20to%20change%20the%20url%20variable%20contents%20for%20your%20own%20Telegram%20API%20or%20those%20of%20the%20same%20SN%20APIs..%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3ESo%20when%20it%20comes%20to%20call%20the%20post%20like%20with%20this%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3Evar%20myDate%20%3D%20new%20Date().toTimeString().replace(%2F.*(%5Cd%7B2%7D%3A%5Cd%7B2%7D%3A%5Cd%7B2%7D).*%2F%2C%20%22%241%22)%3B%0Avar%20post_n%20%3D%20%22%2523Hi.%20It's%3A%20%22%20%2B%20myDate%20%2B%20%22%5Cn%22%3B%0Avar%20post%20%3D%20encodeURI(post_n)%3B%0A%0Aif%20(getMyItem(key%20%2B%20%22htr%22)%20!%3D%20%22yes%22)%0A%7B%0Abot(post)%3B%0AsetMyItem((key%20%2B%20%22htr%22)%2C%22yes%22)%3B%0A%7D%0A%0A%0Areturn%20true%3B%0A%7D%0A%7D()%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2C%20it%20doesn't%20support%20%23%20sign%20in%20my%20browsers%20including%20Chrome%20an%20Firefox%20and%20nothing%20is%20sent%20actually.%20So%20if%20it%20were%20for%20Telegram%2C%20the%20bot%20would%20look%20like%20this%20(and%20I%20donno%20if%20it%20works%20or%20not%20but%20I'm%20talking%20about%20another%20SN)%3A%20var%20url%3D%20'%3CA%20href%3D%22https%3A%2F%2Fapi.telegram.org%2F'%2BToken%2B%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fapi.telegram.org%2F'%2BToken%2B%3C%2FA%3E'...%3C%2FP%3E%3CP%3EPlease%20tell%20me%20how%20to%20send%20%23%20code.%20By%20the%20way%2C%20%22%2523%22%20doesn't%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3221463%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I have a big problem I even don't know where to begin because my code is in Java and I need to use HTML tags too. So the data I'm using is mostly numbers within tables in the webpage and I want to use a specific tag in my code via a result of a row that meets a column (like Excel). I also have another problem:

I'm trying to 'post' the # sign to make some words turn to hashtags in the target url but the code doesn't work and it's via API using this code:

 

true == function()
{
var getMyItem = function (str)
{
if (sessionStorage.getItem(str) == null)
{
setMyItem(str, 0);
return 0;
}
return sessionStorage.getItem(str);
}
var setMyItem = function (key, value)
{
sessionStorage.setItem(key, value);
}

function bot(post)
{
const Http = new XMLHttpRequest();
var Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Token
var ID= "xxxxxx";
var url= 'https://bot.xxx/api/'+Token+'/sendMessage?text='+post+'&chat_id='+ID;
Http.open("GET", url);
Http.send();
}
// you need to change the url variable contents for your own Telegram API or those of the same SN APIs..

 

 

So when it comes to call the post like with this code:

 

var myDate = new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
var post_n = "%23Hi. It's: " + myDate + "\n";
var post = encodeURI(post_n);

if (getMyItem(key + "htr") != "yes")
{
bot(post);
setMyItem((key + "htr"),"yes");
}


return true;
}
}()

 

, it doesn't support # sign in my browsers including Chrome an Firefox and nothing is sent actually. So if it were for Telegram, the bot would look like this (and I donno if it works or not but I'm talking about another SN): var url= 'https://api.telegram.org/'+Token+'...

Please tell me how to send # code. By the way, "%23" doesn't work.

0 Replies