Access 7 days tweets - twitter

I want to get 7 days tweets from twitter and this is my code below:
for(int i=1;i<16;i++)
{
Query qy = new Query();
qy.setRpp(100);
qy.setPage(i);
qy.resultType("Mixed");
QueryResult result = twitter.search(qy);
List<Tweet> tweets = result.getTweets();
}
I got some tweets using twitter4j but I could not control the time of the tweets. I want to get tweets for only 7 days, how can I do that?

If you want 7 days prior to current date, you can use this option
qy.setSince("[YOUR DATE]")
If you want 7 days ahead, try the Twitter Streaming API:
https://dev.twitter.com/streaming/overview
If you want to search between two particular date, Twitter Search does not provide a way to do this but you could "filter" it out using Timestamp of tweets.
Does twitter4j provide the capability to search tweets between 2 dates

Related

Daily views of every video in the channel measured from the release date

I am trying to get the number of views of every video in the channel but measured from the release date for 90 days. I would like something like this:
ID, Release date, 0, 1, 2, 3, 4, ...... 90
Video1, 2020-04-03, 100, 40, 20, 10, ....., 0
Video2, 2020-06-03, 100, 40, 20, 10, ....., 0
...
Is there a way to achive this?
You can achieve this by using a combination of YouTube Data API and YouTube Analytics API requests.
Firstly, query the Data API to retrieve all videos of a channel from the search endpoint.
Set the query parameters to:
part:snippet
channelId:CHANNEL_ID
You will get a list of videos with their details as a response, among others the videoId and publishedAt values. This is what you will need for the second query.
Secondly, query the Analytics API to retrieve view stats of the videos as a video report (differs for content owners and just channel owners).
Set the query parameters to:
dimensions:video,day
filters:video==comma separated list of video ids
metric:views
startDate:earliest published date of all videos
endDate:latest published date of all videos + 90
ids:refer to docs for your owner type
The scope you need for this query is:
yt-analytics.readonly
This query will return views for each video aggregated by day for the date span you provided. After you get the response, you can filter out just the first 90 days for each video.
Alternatively, you can write a separate query for each video with the specified start date and end date, getting a result that does not need to be filtered.
Using the Advanced Tab in YouTube Studio > Analytics you can download your statistics as a CVS-File or open in Google Tables.
That's the quickest way possible.
Hope it helps :)

Get youtube trending videos in specific day and region

The specific information that I want to get is the list of videos that were most viewed in South Korea on Apr 1st, 2020. It would be awesome I can also get the statistics of each videos(such as the number of view counts, likes, dislikes, and comments)
I tried some coding with python using youtube API, but the results seem very different from what I expected. (The title of some videos in the results are written in Arabic or Russian even though their regioncode is KR, I have no idea what's happening.) The followings are my code. Any comments would help. Thx!!
api_key=" "
from apiclient.discovery import build
youtube = build('youtube','v3',developerKey=api_key)
from datetime import datetime
start_time = datetime(year=2020, month=4, day=1).strftime('%Y-%m-%dT%H:%M:%SZ')
end_time = datetime(year=2020, month=4, day=2).strftime('%Y-%m-%dT%H:%M:%SZ')
res = youtube.search().list(part='snippet',
maxResults='50',
regionCode='KR',
order='viewCount',
type='video',
publishedAfter=start_time,
publishedBefore=end_time
).execute()
for item in res['items']:
print(item['snippet']['title'], item['snippet']['publishedAt'])
res
The Search.list endpoint's doc says that:
regionCode string
The regionCode parameter instructs the API to return search results for videos that can be viewed in the specified country. The parameter value is an ISO 3166-1 alpha-2 country code.
This means that filtering a search result set by the regionCode being KR produces a list of videos that are allowed to be viewed in the KR region, regardless of the respective videos being actually viewed from within that region or not.

How to get Date as a segment in Final_URL_Report in Adwords API

Executing my code (using the Google Adwords Library to build an oauth user etc) works when using a query with Month as a segment
String query = "SELECT EffectiveFinalUrl, Cost, Clicks, Impressions,
Month FROM FINAL_URL_REPORT";
But it aggregates across all time, split into months. I am trying to pull in the data as daily aggregates. The documentation has both Month and Date (splitting data into yyyy-MM-dd) as a segment you can include in the query, but Date does not work.
String query = "SELECT EffectiveFinalUrl, Cost, Clicks, Impressions,
Date FROM FINAL_URL_REPORT";
Results in Error 400: Bad Request.
Am I missing something in the documentation that tells me how to resolve this?
Adwords Final_URL_Report Documentation
Try set a date range by adding something like DURING ... to your query.

When making an API call to omniture (site catalyst) , is there any way to use rolling dates

i have created a dashboard in klipfolio and only need 52 weeks data to be fetched by the api with respect to current date .. currenlty i m manualy passing date but i want it to use the system date to automaticall fetch data for me
"dateFrom": "2018-01-10",
"dateTo": "2018-02-05",
You can use Klipfolio's date parameters to accomplish this. In your example, you want the last 52 weeks from today so your query for dates could look like this:
"dateFrom": "{date.addWeeks(-52).format()}", "dateTo": "{date.today}",
Alternatively, if you want it to start on first day of the week 52 weeks ago, your query for dates could look like this:
"dateFrom": "{date.addWeeks(-52).startOfWeek.format()}", "dateTo": "{date.today}",
This will create a 52 week rolling window relative to today so you will not have to update your query every week.

How to query for objects created in last 3 days? [parse.com]

In my app users can post content and i want users to see content from the last 3 days. Is there a wherekey that I can have that only looks for posts from the last 3 days? I am using parse as my backend.
You can use whereKey:greaterThan to solve this.
let threeDaysAgo = NSDate().dateByAddingTimeInterval(-259200)
query.whereKey("createdAt", greaterThan: threeDaysAgo)

Resources