I'm using Twitter's python API to broadcast tweets. Sometimes it works fine. Sometimes it gives me the error "The text of your tweet is too long" for tweets that I believe should be completely legal.
This website explains that all links within a tweet should basically be counted as 20 characters: https://dev.twitter.com/docs/tco-link-wrapper/faq#How_do_I_calculate_if_a_Tweet_with_a_link_is_going_to_be_over_140_characters_or_not
But still it doesn't work for me. I have a tweet that is 132 characters. It includes the link bit.ly/YmoXqw. (That is a made-up link. But the size and form of the link is the same). And it gives me the error above. By my calculations, even if I count this link as 20 characters, it would still come out to 139 characters which is less than 140. So what's the solution here?
Rather than hard-coding the number, you can query help/configuration and use *short_url_length_https* and *short_url_length*. Twitter's Working with t.co Best Practices guidance recommends caching these values up to 24-hours. Twitter recently announced Upcoming t.co changes where the lengths were increasing. You might be seeing that and potentially running into miscalculations on power tweets due to differences in http and https lengths.
Related
I've been using the old url api(v1) to get the count of a given url, lately I needed to get also the re-tweets and started searching about that.
this is the exact url I'm using right now:
http://urls.api.twitter.com/1/urls/count.json?url=http://google.com
As I viewed with some reading the v1 api is deprecated but at least it's still working.
I found some questions on the dev page of twitter:
https://dev.twitter.com/discussions/12643
those are a little old questions and have no specific solving to the problem. I mean, the most near solution was using the search api(search/tweets) which could be good but not a exactly replacement for the urls/count method.
Please note that Twitter's search service and, by extension, the
Search API is not meant to be an exhaustive source of Tweets. Not all
Tweets will be indexed or made available via the search interface.
also it has a limit for 100 results at maximum per 'page', even it throws the link to get the next set of objects, thats good but when the search reaches 1 million of results I'll need to get page over page to now how much tweets I got and having to do to much request to the api...
I sought some question over the dev page on twitter suggested using the stream api, I've tried using (statuses/filter) but that don't work very well given a URL as track param(which they said that is the keyword to track).
So, anyone who's been using the old urls/count has found a reliable alternative with the new apiv1.1, especiffically to get the tweets and re-tweets for a given url ?
The official suggestion by Twitter staff is that either the search/tweets endpoint (having just the last 7 days data) or the Streaming API be used (handling yourself the counters, making everything just too complicated for a d*mn counter).
As an extra warning, the old endpoint (http://urls.api.twitter.com/1/urls/count.json?url=YOUR_URL) will stop working on November 20th, and according to this blog post from Twitter there are no plans to replace it with anything in the short term and they are even removing the count from their own buttons.
I am using the following API call to pull all of the videos with <TAG> from <CHANNEL>:
http://gdata.youtube.com/feeds/api/users/<CHANNEL>/uploads/-/<TAG>/?v=2&alt=jsonc&start-index=1&max-results=50&orderby=published
But for some tag names the results are wrong, or even empty. For example
http://gdata.youtube.com/feeds/api/users/NintendoFR/uploads/-/n3ds/?v=2&alt=jsonc&start-index=1&max-results=50&orderby=published
only has 1 result, but I know that there are at least 20 videos with the tag "n3ds", on the other hand
http://gdata.youtube.com/feeds/api/users/NintendoFR/uploads/-/wiiu/?v=2&alt=jsonc&start-index=1&max-results=50&orderby=published
gives the expected 36 results. Any ideas? Or anyone with similar problems?
Have the same problem (search by tag no longer works).
The Youtube API team has history for making un-announced changes.
For example, a few month's back, the "video description" field was truncated
- without any announcement of the change
- without updating the doco to reflect the change
This looks like a similar change, i.e. tag search has been depreciated (switched off).
Workaround (for your videos) is to include the tag(s) in the first 150 chars or so of the video's description.
We have a similar problem. A few days or weeks ago, a piece of code that sends these requests stopped delivering results. After a bit of research, we found out that getting results is random:
On some occasions we get the right results
On some occasions we get no results.
The only difference we could find in both requests is that a parameter is missing from the requests. When requesting an answer in XML, in the feed node an item is missing:
<feed xmlns:media='http://search.yahoo.com/mrss/'></feed>
Although we do not know why this is, at least now you know that you are not the only one that has this problem.
In my app, I am designing to allow user share messages to twitter. But those messages could already exceeded the 140 character constraint put on tweets, what will be the best way to work around that?
You can't work around the limit. If the 140 characters are exceeded twitter would not accept the message. I suggest you use a tweet-shortener like I do for my app.
What it basically does is if the number of tweets => 140, strip it in half, create a html page containing the full tweet, send back the shortened tweet and the link to the app, then paste it.
But there are already third party tweet-shorteners available so you can try out any one.
http://www.google.com/search?gcx=w&sourceid=chrome&ie=UTF-8&q=tweet+shortener
http://www.google.com/search?gcx=w&sourceid=chrome&ie=UTF-8&q=tweet+longer
It seems like the standard here is to create a shortened URL to the full version of the message to put at the end of the tweet, then fill the remaining space with as much of the message you can fit in 140 characters (with option trailing ellipsis). So, like:
"This is my message I want to share, and it is really lon... http://my.shrturl.com/aJdD"
Also, take a look at TwitLonger maybe? http://www.twitlonger.com/
full explanation:
I'm working on a project to generate twitter links that post over to twitter. My problem is twitter doesn't shorten the text correctly, and asks the user to fix the text. So I'm going to have javascript shorten the text to the maximum allowed without the extra being cut off by the user or twitter.
That's an unknown number because bitly will add characters as the namespace runs out. So it might be 21 today but 22 in a year. You may need to create the bitly links yourself before posting to Twitter.
This page tells you how to retrieve the current maximum length of a t.co URL generated by Twitter in real time, as part of a JSON string returned via a RESTful HTTP interface:
Twitter RESTful API Description
The relevant values shown for the sample request (YMMV) are:
"short_url_length_https": 23
"short_url_length": 22
These values will change (increase) monotonically over time, as Twitter runs out of combinations to represent the number of URLs submitted (and shortened) thus far.
According to this FAQ from Twitter:
https://dev.twitter.com/docs/tco-link-wrapper/faq
"The maximum length of t.co URLs will change over time. Issue a request daily to GET help/configuration and examine the fields short_url_length and short_url_length_https to determine the current maximum length of wrapped URLs. We do not expect these values to change often."
If your users are providing their own large links, Twitter should now shorten these correctly. At the time of your post, there might possibly have been some problem with that, but at the present time I think that this is working correctly.
However, you might want to provide more meaningful-looking shortened URLs, and Twitter supports this with something called Tweet Entities. I have not used these myself, but here is a link describing them:
Tweet Entities
Hi all
I am new to twitter API.. So my question may be a trivial one..
I am developing a new twitter widget, in which I want to get the first tweet for a given hashtag on a particular date.
say first tweet for #xyz hashtag tweeted on 12-08-10.
so far through googling and api doc I found rpp * page max = 1500.. if totaltweet for a given day is 2000 how can I retrieve last 500 tweets..
I have a few questions?
1. Is this for any hashtag that a user might request on the fly, or a set of hashtags that generally remain the same?
If it is a set of tags that stays the same for a while, roughly how many tags are there?
When you say a particular date, how far back in time are you going?
There are two standard ways to get tweets for a hashtag. You can use search, which goes back around 7 days or 1,500 tweets. For an active tag, that may only be a day or two. You can use the streaming API, but that doesn't go back, it just starts tracking from the moment you start making the request. The streaming API can track up to 400 hashtags without getting approval for a higher rate. The search API is limited to 10 to 20 hashtags per query.
If you answer questions 1-3, I can suggest a path to getting what you want.