I just want to confirm what is the actual Twitter Direct message length when a media is attached?
Currently we observe that it's going down to 9,976 but can't find any twitter official notes. All I can find is one of the many sites that says it's 10,000 characters.
https://marketingland.com/twitter-will-increase-dm-character-limit-from-140-to-10000-131947
Here's the sample JSON payload with attachment
{
"event":{
"type":"message_create",
"message_create":{
"target":{
"recipient_id":"xxxxx"
},
"message_data":{
"text":"Post Man Test with media. Max character is reduce to 9,976 instead of 10,000...",
"attachment":{
"type": "media",
"media": {
"id": 1243471116468800000 }
}}}}}
Without the attachment object, max characters becomes 10,000
When media is attached, the message will contain a t.co link to the image itself. The length of t.co links is currently 23 characters, so (with a single character space to separate from the text) this would match the length you are seeing.
You can confirm this by checking the Twitter help/configuration endpoint, which returns:
"short_url_length_https": 23
So, yes, the maximum text length with an image in a Direct Message would be 10,000-24, i.e. 9,976 characters. Unlike a regular Tweet, Direct Messages do not have the ability to "discount" the media link from the body of the message.
Related
A correct JSON is
[{
"user_id": 1,
"user_name": "John Doe I"
}, {
"user_id": 2,
"user_name": "Jane Doe III"
}]
But if it contains some illegal characters it will not validate. Like this with a CR after Doe:
[{"user_id":1,"user_name":"John Doe
I"},{"user_id":2,"user_name":"Jane Doe III"}]
My question is if there is a "clean up" function in Omnis Studio 8 where the output is a correct JSON?
EDIT
To replace or delete KNOWN characters is easy. The problem is that text copied from MS Word and the Web can contain UNKNOWN characters. So I am searching for a command like
Calculate VALIDJSON as keepvalidchar(NOTVALIDJSON)
Is there such a beast?
according to this post How do I handle newlines in JSON?
if you want newlines in a text string, you need to escape the \n. so \n in a the original json string should be valid replacement for a 'cr'. eg.
[{"user_id":1,"user_name":"John Doe\nI"},{"user_id":2,"user_name":"Jane Doe III"}]
My read on this is that if you are pulling the data out of a database to send some place on the web, you might want to escape the newline to retain it in the text, rather than altering the JSON after the fact. Of course, that depends on the purpose of the API call to the server receiving the json.
I guess the crux is
if you want the json to reflect the original text content including special characters, you escape it
if you don't, then you remove it. I'd probably clean the original source since I might want to leave the json formatted and doing a replace of \n for blank .. might not have the effect you want.
Are you simply looking for a
do replaceall(lcVar,kCR,'\n') Returns lcVar
function call?
Thus replacing the CR character with the escaped normal encoding of '\n'
I guess the other question is, are you creating the JSON to send, or receiving the JSON and trying to decode it?
If receiving, maybe OJSON.$formatjson() may help?
What characters can I use in a Dailymotion video title (UTF-8) ? Are there any forbidden chars ("<>") ? And what is the maximum length of a video title ?
The title of a video needs to have a length between 1 and 255 characters and accepts any UTF-8 charater.
You can find all the list of our guidelines here: API guidelines
I read through similar stackoverflow questions to understand financial track card data.
I think the issue I am facing might be slightly different or maybe I am really weak in regex.
Now we have a service that returns track data accidentally instead of the guest name.
My goal is every time I receive track data I display "" empty string, else return the guest name.( This is a temp solution until we fix the root cause)
This is what my regular expressions is but looks like it doesn't detect track data.
irb(main):043:0> guestname="%4234242xx12^TEST/GUEST L ^324532635645744646462"
irb(main):044:0> (/[(%[bB])(;)]\d{3,}.{9,}[(^.+^)(=)].+\?.{,2}/.match(guestname)) ? "" : guestname
=> "%4234242xx12^TEST/GUEST L ^324532635645744646462"
(Not real data)
Now, looking at the wiki for track data information I want to cover most cases, if not all:
https://en.wikipedia.org/wiki/Magnetic_stripe_card#Financial_cards
Could some help with my regex. This is what I have:
/[(%[bB])(;)]\d{3,}.{9,}[(^.+^)(=)].+\?.{,2}/
Track 1, Format B:
Start sentinel — one character (generally '%')
Format code="B" — one character (alpha only)
Primary account number (PAN) — up to 19 characters. Usually, but not
always, matches the credit card number printed on the front of the
card.
Field Separator — one character (generally '^')
Name — 2 to 26 characters
Field Separator — one character (generally '^')
Expiration date — four characters in the form YYMM.
Service code — three characters
Discretionary data — may include Pin Verification Key Indicator (PVKI,
1 character), PIN Verification Value (PVV, 4 characters), Card
Verification Value or Card Verification Code (CVV or CVC, 3
characters)
End sentinel — one character (generally '?')
Longitudinal redundancy check (LRC) — it is one character and a
validity character calculated from other data on the track.
Track 2: This format was developed by the banking industry (ABA). This
track is written with a 5-bit scheme (4 data bits + 1 parity), which
allows for sixteen possible characters, which are the numbers 0-9,
plus the six characters : ; < = > ? . The selection of six
punctuation symbols may seem odd, but in fact the sixteen codes simply
map to the ASCII range 0x30 through 0x3f, which defines ten digit
characters plus those six symbols. The data format is as follows:
Start sentinel — one character (generally ';')
Primary account number (PAN) — up to 19 characters. Usually, but not
always, matches the credit card number printed on the front of the
card.
Separator — one char (generally '=')
Expiration date — four characters in the form YYMM.
Service code — three digits. The first digit specifies the interchange
rules, the second specifies authorisation processing and the third
specifies the range of services
Discretionary data — as in track one
End sentinel — one character (generally '?')
Longitudinal redundancy check (LRC) — it is one character and a
validity character calculated from other data on the track. Most
reader devices do not return this value when the card is swiped to the
presentation layer, and use it only to verify the input internally to
the reader.
Your example input string does not contain format code after first sentinel.
You are trying to parse html-encoded version, which is weird.
So, I would start with html decoding. E.g. with Nokogiri:
▶ guestname="%4234242xx12^TEST/GUEST L ^324532635645744646462"
#⇒ "%4234242xx12^TEST/GUEST L ^324532635645744646462"
▶ parsed = Nokogiri::HTML.parse(guestname).text
#⇒ "%4234242xx12^TEST/GUEST L ^324532635645744646462"
OK, now we at least have a leading percent. Now let us ask ourselves: how many users have a guest name starting with a percent sign? I bet none. You might re-check yourself by running a query against your database. Since it is a temporary solution, I would definitely shut the perfectionism up and go with:
▶ parsed =~ /\A%/ ? '' : parsed
Hope it helps.
I'm trying to figure out how to allow posting of special commands during statuses/update. the API documentation stats that if post tweets stating with "D ", "M " it will send a direct message to the user after the command.
I tried replacing the first character with a "no-break space" (%A0). However twitter translates these characters to �.
The only other option I can think of is creating a regex which strips out all potentially hazardous SMS code. This isn't ideal since I would prefer to keep the raw tweet. Such as tweeting: "D Day was an alright movie." would result in "Day was an alright movie."
I also tried entering a space before the post but it just got ignored and still sent a direct message. Is there some sort of escape character or cheat to make twitter ignore these commands?
Looks like I found the solution. There were a few issues. 1st was my percent encoding function wasn't accepting unicode characters so twitter was responding with a �. To resolve this I used the following code in VB.Net:
Regex.Replace(Uri.EscapeDataString(s), "[\!\*\'\(\)]", Function(m) Uri.HexEscape(Convert.ToChar(m.Value(0).ToString())))
The second issue is twitter treats all white space characters the same. So you can't cheat and use a character such as u+00A0 (No-break space) or any other character listed in:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf (6.4)
http://en.wikipedia.org/wiki/Whitespace_character
Luckily twitter does not include zero-width spaces as a white space character. As well twitter actually allows for 141 characters to be posted through the API if using a zero-width space. This means you can add U+200B after the SMS command and before the space to prevent the SMS command from running. Such as:
Dim s as String = "M" & ChrW(8203) & " Username 140 character tweet posted here as a test. This is actually 141 characters because of the zero-width space. But accepted anyway."
Hope this helps!
Update:
For those who are looking for the regex code to do this, it's a 1 liner:
Regex.Replace(s, "^(ON|OFF|FOLLOW|F|UNFOLLOW|LEAVE|L|STOP|QUIT|END|CANCEL|UNSBSCRIBE|ARRET|D|M|RETWEET|RT|SET|WHOIS|W|GET|G|FAV|FAVE|FAVORITE|FAVORITE|\*|STATS|SUGGEST|SUG|S|WTF|HELP|INFO|AIDE|BLOCK|BLK|REPORT|REP)( )", Function(m) m.ToString.Replace(" ", ChrW(8203) & " "))
In my application I need to get the SIM card number. I am getting that with SIMCardInfo.getIMSI(), but in some other format.
My SIM number is 89919400002018929130, but I am getting: 404940.20.189291.3
I used the following code:
try
{
currentSimNo = GPRSInfo.imeiToString(SIMCardInfo.getIMSI());
}
catch (Exception e)
{
}
The imeiToString takes a IMEI not a IMSI
sampath says:
My SIM number is 89919400002018929130, but I am getting: 404940.20.189291.3
If I line up your two numbers and remove separators, it does look like they are roughly the same:
89919400002018929130
404940201892913
Where did you get the first one from?
In the Wikipedia article on IMSI, you can see that the first three digits are the MCC, then the second three are the MNC. So it looks like your SIM is from India, though I don't see a MNC that matches 940.
These values are frequently encoded as binary-coded decimal, which is why the imeiToString method needs to be used.
EDIT
The IMSI wikipedia article also mentions:
An IMSI is usually presented as a 15 digit long number, but can be shorter.
I think your code is returning the correct value as 404940201892913. Whatever number you are trying to compare it to (899194...) must be encoded differently.