Fetch changed/new videos using YouTubeData API - java

I am using YouTube Data API v3 to authorize a user with my app to fetch the video details from their channels and their subscribed channels and index those details to Elasticsearch.
I'm following this SO Answer to fetch all videos under a channel. Now, I met with a situation that I had to take only new videos in my next fetch. But, when I fetch again it also contains the videos that are already fetched earlier. I didn't find anything on this on YouTube Data API's documentation. I think this requires any token or any cursor field that handles the changes.
Looking for some suggestions.

You can save the 'last fetch date' and then, use /search to filter by date adding publishedAfter as a filter in your request. You hace a lot of filters in the search like the channelId, channel type, etc.

Related

How to use Java and Twitter API to get tweets sent by given Twitter ID?

I want to use java and Twitter API to collect Twitter data for researching, especially to collect tweets sent by a given Twitter ID.
Now I can only collect my own tweets by using Twitter4j and OAuth setting. How could I get others tweets if I could not get their OAuth?
There is no restriction to collect others tweets, so what I mean is you don't need to have a specific authhentication token for this. Only restriction might be protected accounts owners because protected accounts don't allow anyone to get their tweets without establishing friendship association like following mechanism.
You can look at both dev.twitter.com and twitter4j sites how to do that. By the way, I recommend twitter4j. If you have further questions, let me know I can help more as well.
Java4j Code Examples
The method you're looking for is:
getUserTimeline(java.lang.String screenName)
or:
getUserTimeline(long userId)
This will give you the latest 20 Tweets of the required user. So your code should look something like this:
Twitter twitterConnection = getConnection(); //I assume you already know how to init a connection
ResponseList<Status> results = twitterConnection.getUserTimeline("justinbieber");

Get User Name and Channel ID from YouTube API

I'm using Android to access both the YouTube Analytics API and the YouTube Data API. Currently I have the app working that if I hard code in my personal Channel ID the app can retrieve information about my personal YouTube account.
However, I am using the Android AccountPicker to use GoogleAuthUtil so I have access to the user's email address. Is there a way to query YouTube to return their Channel ID using their email address?
Also is there a way to query YouTube to just receive back the user's User Name? I would like to greet them when in my app.
Thanks in advance!
~Jskuzma
You can call channels->list with "part=id & mine=true"
GET https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key={YOUR_API_KEY}
Id is the channel's ID.
You can get the video's title from the response under [snippet.title].
You can get the channel's title from the response under snippet.channelTitle.
This title is what you are looking for to greet, but if you want to go deeper you can check if that account is linked with Google+ and use googleplususerid to retrieve more information via Google+ API.

Facebook realtime api for feed

I have set up realtime feed update for user. So whenever a user comments or likes something, I get a update request from facebook.
{
object='user',
entry=[{
uid='1372299847',
id='1372299847',
time=1368760855,
changedFields=[feed]
}]
}
But this doesn't tell me what the update exactly was. I have to read that user's feed and see what is the new change and process it. If I get the id, then I can just request for that object and process it rather than reading his feed and getting the changes.
Is there any way to get what exactly was changed(id of the comment or status)?
Facebook doc says that you have to get the actual changeset via Graph API or FQL query. The notification you get tells you only the concerned user's ID.

How to retrieve all the tweets of my followers through the twitter streaming API with twitter4J?

I'm using the following Code with the twitter4J library to retrieve all tweets of my followers:
friendsIDs = TwitterConnectionManager.getTwitter().getFriendsIDs().getIDs();
twitterStream = twitterStreamFactory.getOAuthAuthorizedInstance(getTwitterAccessToken());
twitterStream.filter(new FilterQuery(friendIDs));
This provides me with all tweets that are from one of my friends but also tweets that contain #username of one of my friends. If I'm following an account like Twitter I get all Tweets containing #Twitter. I'm filtering this tweets after they arrive but they create a lot of unneeded data and CPU usage and since I use this code on a mobile device I would like to create a filter that gives me only the tweets that appear in my timeline.
I don't think this is possible. Take a look at the docs for the filter endpoint here:
http://dev.twitter.com/doc/post/statuses/filter
Maybe you could put an app-server between your mobile apps and the twitter api that does the filtering?

How can I correlate the response from Google Checkout to the correct order in the database?

When I get the notifications from google at the callback URL I am unable to correlate the messages to the correct order in the database. Can I pass some identifier that would be sent back to me as a part of the callback notification? How is this done in general?
I am using the latest google-checkout-java SDK.
You should be able to use your merchant-private-data-section for this
<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
<shopping-cart>
<merchant-private-data>
<your-ref>019b1723a2754981ed5bc24e6ac9f501</your-ref>
</merchant-private-data>
[...]
</shopping-cart>
</checkout-shopping-cart>
When you get the notification, you can read this data.
See also this question and especially this answer. I'd only note additionally that you don't have to use merchant-note (or your-ref), but can define any tags of your own as merchant-private-data is defined as a sequence of xs:any.
Hope that helps...

Categories