How to avoid link break or hashtag break in tweet status trimmed by LinqtoTwitter?

Nov 19, 2013 at 11:18 AM
I am using LinqTOTwitter for retrieving user status and displaying it to our site, but when tweet size is more then 140 character, it trims the tweet. So if at end of tweet, there is a link, it will break. How can I avoid this?

For getting my tweet status from LinqTOtwitter, I am using following code.
List<Status> tweetstatus = 
(from stat in twitterCtx.Status 
where stat.ScreenName == ScreenName && 
stat.Type == StatusType.User && 
stat.IncludeEntities == true 
select stat).ToList();
Coordinator
Nov 19, 2013 at 4:22 PM
Hi,

In Twitter, Tweets can only be 140 characters. LINQ to Twitter doesn't do anything with the tweet, except for parsing Json into a Status entity. Or am I misunderstanding your question?

@JoeMayo
Nov 20, 2013 at 5:41 AM
Hi Joe,

Thanks for reply, I know after 140 character tweets truncate. If in the tweet last characters are in form of link then links are broken but in case of twitter that is not happen. e.g we are getting tweets like this "RT @richfreestone: Thanks to @groundworkuk for their work on my story, from having nothing at all and working towards my career http://t.co…" while in twitter "Thanks to @groundworkuk for their work on my story, from having nothing at all and working towards my career http://www.groundwork.org.uk/Blog/richards-story …" but in twitter if we click on link its working but in our site its not working.
Are you getting my point now? Could you suggest something on this?
Coordinator
Nov 20, 2013 at 6:31 AM
I see. Look at the Entities to see if there's a URL entity. It will have start and stop positions and the URL that the link goes to. Do you have an example StatusID?

@JoeMayo
Nov 20, 2013 at 6:39 AM
I have checked I got 2 mention but 0 URL entity. I have StatusID i.e. "402457777886347264". I have posted code above by using that code I am getting tweet status, do I need to change that?
Coordinator
Nov 24, 2013 at 7:26 PM
I looked up this tweet, with the status ID you provided, and the text is 136 characters:
_This year we supported 4,500 community organisations like the Burgess Park Food Project to create better places:  http://t.co/XZivjbFEC2_
The URL on the end is a Twitter t.co url. If you hit a breakpoint, look at the Entities property of the Status instance. It has a UrlEntities collection with one item. That one item is for the t.co URL in the text. In this case, it's an ow.ly shortcut.

I found the tweet you're referring to in the previous post - used the id you gave me, found the user, looked at the user's timeline, and visually matched the tweet with some of the text you gave me. Here's the Text:
_Thanks to @groundworkuk for their work on my story, from having nothing at all and working towards my career http://t.co/Y1sO9cDK6j_
That's 131 characters. If you look at the Entities property, there's a UrlEntity for the t.co in the text above and it's Expanded Url is: http://www.groundwork.org.uk/Blog/richards-story that matches the text in the message that starts at position 109 and ends at position 131.

Replace the t.co url with any text you want and wrap that in a hyperlink for the ExpandedUrl.

Does that answer your question?

@JoeMayo on Twitter
Jan 2, 2014 at 7:25 AM
Hi Joe,

Sorry for my late reply. My question is still there, in above tweet is 131 character but when I show this tweet status in our site its say RT <TweetID> then after tweet text. Now it become more then 140 character. In my case with using above code tweetstatus in that I am not getting any URLEntities in Entities section.
Could you suggest any solution/link where I can replace t.co text in the message?
Coordinator
Jan 2, 2014 at 4:48 PM
That's the way the Twitter t.co wrapper works. Here's more guidance:

https://dev.twitter.com/docs/tco-url-wrapper

@JoeMayo
Jan 3, 2014 at 6:29 AM
Are you getting my point what I want? My question how we can avoid break of URL in our status? As you said above about URLEntities "The URL on the end is a Twitter t.co url. If you hit a breakpoint, look at the Entities property of the Status instance. It has a UrlEntities collection with one item. That one item is for the t.co URL in the text. In this case, it's an ow.ly shortcut. " but I am not able to get any UrlEntities here see image
Image