twitter api - get retweet screen name from user_timeline - twitter

Disclaimer - Not a twitter user, and first time using the api.
The good - I'm able to use user_timeline to get back tweets from a screen name.
example - api.twitter.../user_timeline.json?screen_name=cnn&include_rts=1
The bad - The reponse doesn't list the tweet URL, but from the screen name and Id, I can recreate it.
example - twitter.com/cnn/status/512610874323116032
The ugly - For retweets, I don't see the retweet screen name, so I can't recreate a url to the tweet.
example - getting tweets for cnn may have a retweet like "CNN iReport #cnnireport"
From what I can tell, the user_timeline doesn't tell me that the tweet was from "cnnireport", so I don't know how to create the twitter.com/XXXXXXXXXXXXXX/status/512610874323116032 url.
Am I missing something basic? Seems like this would be a common scenario. Can somebody give me a dope slap and get me on track?
All advice is appreciated

You can get the extended retweet information by making a request to statuses / retweets / :id.
So get the user timeline -
https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=cnn&include_rts=true
then use the retweeted_status.id_str (ID) in the response and get -
https://api.twitter.com/1.1/statuses/retweets/ID.json

Related

How can I return all songs by Album (collectionID) from Apple itunes search API

I want to do something like this:
https://itunes.apple.com/lookup?collectionid=211192863&entity=song
But it doesn't return the songs
I'm pretty sure they have such parameter since it is a pretty basic one
any tips are appreciated
Edit:
it seems I can pass ID also, but I don't know if I can trust it once I usd id input for artist search as well
You are very close - the proper API request should be:
https://itunes.apple.com/lookup?id=211192863&entity=song
Note, the first result returned is the Collection meta data, each of the following 12 results are the track meta data.
Your url is wrong, for search API url you should see below:
https://itunes.apple.com/search?id=211192863&entity=song&media=music
enjoy!!!

How do I get latest tweet by specific user and specific hashtag

May I know how do I get latest tweet by specific user and specific hashtag
On twitter GET Search no parameters option for the username or userid
Let's say I want to search tweet from username stackoverflow with #php hashtag.
You would have to custom code the second part.
Use https://dev.twitter.com/docs/api/1/get/statuses/user_timeline - to get the latest tweets from a specific user.
Write Code to search within the response Object of (1) with the hashtag (search-key).

Twitter - Favorite a tweet?

I have Aouth working for Twitter, and pulling in a stream of tweets, I am trying to figure out how to then Favorite one of the Tweets coming in from the stream.
I understand twitter's API give me this:
Parameters:
* id. Optional. The ID or screen name of the user for whom to request a list of favorite statuses.
o Example: http://api.twitter.com/1/favorites/bob.json or http://api.twitter.com/1/favorites/bob.rss
* page. Optional. Specifies the page of favorites to retrieve.
o Example: http://api.twitter.com/1/favorites.xml?page=3
But that doesn't really help me in trying to implement, or I just am not sure how to approach it
Any help ?
POST favorites/create on twitter development site
Did you try this?
function Like(ScreenName, TweetID)
{
client.rest.post('favorites/create', { screen_name: ScreenName, id: TweetID});
}
Something like this in JavaScript.

Twitter: Number of tweets OR get more tweets

I would like to know how can I get all tweets from a certain hash tag?
I am currently using the following code:
xhr.open("GET","http://search.twitter.com/search.json?q=%23PrayForJapan");
This only returns me 15 tweets. Does anyone know how to make it return more?
Also, I have got a code to get me the tweets of a certain screen name, this only returns 20 tweets, how can i ask the following 20 tweets?
The code i used for that is:
xhr.open("GET","http://api.twitter.com/1/statuses/user_timeline.json?screen_name=Eminem");
I'm using titanium to create this, but I don't think that is an issue?
Thanks!
You can usually add count=x as parameter to the query string to get up to x tweets (for the search api it seems to be rpp). Query string parameters are added to the base url via ? and each individual parameter is then separated by & as in http://api?user=1&count=4
Most of the time, it is better though to remember the last tweets and then add ?since_id=x as this way you only get tweets you did not see before.
Have a look at the api documentation.

Twitter API - Display all tweets with a certain hashtag?

How would I go about displaying tweets that contain a certain hashtag using the Twitter API? Thanks
I'd also like to know if there is a way to get all tweets from a certain hashtag in a separate file, also the ones that don't show up in your feed anymore. I suppose that's what the earlier question was about, too.
This answer was written in 2010. The API it uses has since been retired. It is kept for historical interest only.
Search for it.
Make sure include_entities is set to true to get hashtag results. See Tweet Entities
Returns 5 mixed results with Twitter.com user IDs plus entities for the term "blue angels":
GET http://search.twitter.com/search.json?q=blue%20angels&rpp=5&include_entities=true&with_twitter_user_id=true&result_type=mixed
UPDATE for v1.1:
Rather than giving q="search_string" give it q="hashtag" in URL encoded form to return results with HASHTAG ONLY. So your query would become:
GET https://api.twitter.com/1.1/search/tweets.json?q=%23freebandnames
%23 is URL encoded form of #. Try the link out in your browser and it should work.
You can optimize the query by adding since_id and max_id parameters detailed here. Hope this helps !
Note: Search API is now a OAUTH authenticated call, so please include your access_tokens to the above call
Updated
Twitter Search doc link:
https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html
The answer here worked better for me as it isolates the search on the hashtag, not just returning results that contain the search string. In the answer above you would still need to parse the JSON response to see if the entities.hashtags array is not empty.

Resources