How to get all posts in a limited date range in Instagram Graph API? - instagram-graph-api

I need to retrieve all posts from the instagram page associated to my business account.
The Instagram API documentation does not mention any way to get media only between a certain period.
I´ve tried a analog request with the one I use in Facebook API
/{my_business_account_id}/media/?limit=100&period=day&access_token={my_user_access_token}&since=2019-02-23&until=2019-02-24&fields=id,caption,like_count,media_type,media_url,timestamp,permalink,username
That request works but ignores the since / until parameters and retrieve literally all my posts.
How do I limit the date range of the retrieved posts?

Answer is here: https://stackoverflow.com/a/50946962/5696380:
Unfortunately the since and until parameters are not supported on
this endpoint and this endpoint has only support cursor based
pagination.

Related

How do I retrieve a user's tweets of last 7 days using twitter API?

I want to pull tweets from an authenticated user's home timeline (user + people the user follows) of past 7 days. How can I do this? The documentation of GET statuses/home_timeline only provides a count parameter and some other parameters like since_id and max_id which I don't really understand.
Documentation: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-home_timeline
Is there any other endpoint which might help? Or is it just impossible to do so?
The recent search in the Twitter v2 API can do what you are asking.
Here is an example:
https://api.twitter.com/2/tweets/search/recent?query=from:username is:verified&max_results=100
The Research Search API can only search in the last 7 days by default. You can return a maximum of 100 tweets per request.
Docs:
https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-rule

Is it possible to access the live tweets of a user using tweepy?

I am trying to access live tweets of a user whenever he tweets it. So, all I want is something that continuously monitors a user account and whenever he tweets something I have to capture it. All the tweets are random so I cannot use any filters.
For any security reasons, if I cannot access other's tweets can I do it on my own account?
With tweepy you can connect to the REST API or the Streaming API.
Using the Streaming API you can use the filter endpoint to select the users you wish to follow with that streaming connection and you will receive updates as they get published.
Twitter's documentation: https://dev.twitter.com/docs/api/1.1/post/statuses/filter, tweepy's code: https://github.com/tweepy/tweepy/blob/master/tweepy/streaming.py
Tweepy's documentation doesn't give examples on the Streaming functions but you can find sample code searching at GitHub or StackOverflow for "tweepy filter follow".
Tweepy talks to the Twitter REST API, and the REST API doesn't have any way to react to someone posting a tweet.
HOWEVER...
You could certainly write an application that retrieves the tweets of a partcular user and looks for any tweets that weren't there the last time you checked.
You'd want to be cautious about how often you check so you don't run afoul of the API rate limits.

YouTube Analytics API Questions

I'm new to the YouTube Analytics API, and had a couple of questions:
In order to retrieve Analytics reports, I have to specify the channel ID for the "ids" parameter. How do I find the channel ID for the OAuth-authenticated user? I saw in the Sample Application that I can call Channels.list method in the Data API (V3) and use the "mine=true" parameter. Is this guaranteed to return a single channel? If not, how do I know which channel is the right one? What's the recommended way of finding a user's channel ID?
Once I have the channel ID, I can begin querying for Analytics data. I'd like to query the "views" metric for the channel for the entire history of that channel. The question is, how do I know how far back to query? Is there a channel start date? The Channels.list method mentioned above doesn't return the snippet.publishedAt date for my channel so that doesn't seem to be a reliable way. How else do I know when to stop? I guess I could query back until 2005 or so when YouTube was founded but that seems like a bad approach. Any suggestions?
The Analytics API supports reports for channels as well as content owners. Once a user authenticates via OAuth, how do I know if that account is a regular YouTube account vs a CMS content owner account?
Any help would be greatly appreciated!
The recommended approach is to do a channels.list(mine=true). The first result returned will be the channel corresponding to the currently authorized user. (channels.list() returns a list of channels because there are other combinations of request parameters that could result in more than one channel being returned.)
Going back to some arbitrary date in the past should be harmless. 2005, 2000, etc. The YouTube Analytics backend should know how to properly deal with that, and you'll obviously only get stats that date back to the first views associated with your channel.
The value of the ids= parameter tells the API whether you want to do a report against a channel associated with the current authorized user (ids=channel==UC...) or against channels/videos that you have access to as a CMS content owner (ids=contentOwner==CONTENT_OWNER_NAME).

How can I get the number of Tweets a link has using the Twitter API?

I want to see how many tweets does a link have. For Facebook, you can use FQL to get the number of Likes each page has.
Is there a page in the Twitter API documentations that describe how to do this?
This seems to work, without authentication:
http://urls.api.twitter.com/1/urls/count.json?url=example.com
For example, to get the number of tweets for this random page on mashable:
http://urls.api.twitter.com/1/urls/count.json?url=http%3A%2F%2Fmashable.com%2F2012%2F01%2F21%2Ftop-10-tech-this-week-13
Returns the following JSON:
{"count":1204,"url":"http://mashable.com/2012/01/21/top-10-tech-this-week-13/"}
Twitter hasn't released any developer APIs for analytics based on links (assuming you're only interested in links that are wrapped by the t.co wrapper). You can look at the existing documentation but it's not very good.
I don't believe there will be any API for getting the number of tweets that link to an arbitrary url.

Using oAuth to retrieve tweets of a particular ID (equivalent to a page in facebook)

I need to know as to how to implement oAuth in an iphone application.
I have already gone through lot many posts but none of them shows as to How to retrieve tweets from a user profile (like we access facebook wallposts). I tried using an example named bengottlieb/Twitter-OAuth-iPhone but all it does is show the Login prompt and posts a sample Twit at my Twitter profile.
I need to make an application where
the user can view twits for a particular page (same as accessing the wall post for a Page)
Post tweets that will appear on his profile or if possible then also at the profile page for given ID
I was able to fetch the tweets for a particular id using http://search.twitter.com/search.json?ID but may be due to closing of Basic authentication it does not return to me tweets older than a specific time period.
The Twitter search API is not meant to retrieve the tweets from one particular user, even though it does seem to work (up to a certain point back in time). As far as I know the search API does not need authentication, so you're not in trouble regarding the deprecation of Basic authentication there.
To retrieve the tweets for a user, you need to retrieve their timeline. Be sure to use OAuth authentication, as indeed Basic authentication no longer works now.
Check out http://dev.twitter.com/ for more information. The API is documented quite well. You mention basic authentication, so perhaps you could start with http://dev.twitter.com/pages/basic_to_oauth to get you going?

Resources