I'm trying to get the friend's tweets count using twitter4j. so far I was up to getting ID of friends with below code.
accessToken = twitter.getOAuthAccessToken(requestToken, oauth_verifier);
SharedPreferences.Editor edit = pref.edit();
edit.putString("ACCESS_TOKEN", accessToken.getToken());
edit.putString("ACCESS_TOKEN_SECRET", accessToken.getTokenSecret());
User user = twitter.showUser(accessToken.getUserId());
IDs friend_ids = twitter.getFriendsIDs(accessToken.getUserId(),-1);
Log.d(TAG, "friend_ids "+friend_ids.toString());
Log.d(TAG, "friend_ids.getIDs() : "+friend_ids.getIDs());
I found many posts to get tweets but those are with making a REST call. I would like to know the way to get the tweets count from my above code.
From your code you only gets the id's, so you can't.
But you could use lookupUsers to get info from 100 users at the time, so you can get the status count from that info.
Related
we have a product that will subscribe a user to another user(s) after they go through and give us full permission to do so. The user is then subscribed to these other user(s) ... you can see this in youtube after the API is performed (seems successful) ... but a day later the subscribers are removed and gone? This always worked well. Anyone experience similar issues or know the why here?
When using the API with full permission scope, we Subscribe the user to a channel and we get varying results :
the Google_Service_YouTube_Subscription_Object is returned with valid data
The channel Subscription https://www.youtube.com/subscribers?ar=2&o=U may or may not increase in value (counter at top)
The channel Subscriber list https://www.youtube.com/subscribers?ar=2&o=U is not showing the new user (subscriber)
The user shows in their Youtube view that they are subscribed to the Channel
the user Comment on the video is displayed depending on the user privacy settings
the user Like on the video is counted
the NEXT day: comments, subscriber counts are removed from the Channel, likes on the video seems to stay
$youtube_client = new \Google_Client();
$youtube_client->setClientId(xxxx);
$youtube_client->setClientSecret(xxxx);
$youtube_client->setScopes(xxxx);
$youtube_client->setRedirectUri(xxxx);
$youtube = new \Google_Service_YouTube($youtube_client);
$resourceIdyt = new \Google_Service_YouTube_ResourceId();
$resourceIdyt->setChannelId($channel);
$resourceIdyt->setKind('youtube#channel');
$subscriptionSnippetyt = new \Google_Service_YouTube_SubscriptionSnippet();
$subscriptionSnippetyt->setResourceId($resourceIdyt);
$subscriptionyt = new \Google_Service_YouTube_Subscription();
$subscriptionyt->setSnippet($subscriptionSnippetyt);
$subscriptionResponse = $youtube->subscriptions->insert('id,snippet', $subscriptionyt, array());
This question already has answers here:
Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
(8 answers)
Closed 5 years ago.
I'm trying to retrieve all user's friends and render them in a list view using facebook graph request.
const infoRequest = new GraphRequest(
'/me',
{
parameters: {
fields: {
string: 'email, name, first_name, middle_name,
last_name, picture.type(large), cover, birthday, location, friends'
}
}
},
this._responseInfoCallback
);
Facebook doesn't allow you to access your full friends list anymore since API 2.0, just those who also use your app. https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends.
For further reference you can also check the post Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app
If you still have any queries please let me know. :)
EDIT
You can get the list of friends of the user which are not using this app with the api call given below:-
https://graph.facebook.com/' + facebookUserId +
'/invitable_friends?access_token=' + userToken
and then inside the callback of the above api call you can make a new api call and get the list of users friends which are using the app with the call given below:-
https://graph.facebook.com/' + facebookUserId + '/friends?access_token=' + userToken
and then you can concat the result of both the api calls and get the list of all the friends of the user as below:-
let allFriends = firstApiResponseArray.concat(SecondApiResponseArray)
Now allFriends will give the list of all the friends of the user. I hope this is what you are looking for :)
I just implemented a friend adding system and I'm scratching my head on how to only allow users to see friend's posts.
On my main screen where I'm displaying posts, I've got :
DataService.ds.REF_USERS.child(currentUser!).child("friends").observeSingleEventOfType(.Value) { (snapshot: FIRDataSnapshot) in
for snapshots in snapshot.children.allObjects {
let snap = snapshots as! FIRDataSnapshot
var frand = String(snap.key)
self.friendsArray.append(frand)
}
which pulls back the UID of all their friends.
I then want to search through all posts that have that UID as a child.
I figured maybe I could do a for-loop through the friendsArray with an equalTo query...? but then I'm not sure how to implement that with my currently existing query that shows back posts that I'm wanting to see :
DataService.ds.REF_POSTS.queryOrderedByChild("timestamp").queryStartingAtValue(cutoff).observeEventType(.ChildAdded, withBlock: { (snapshot:FIRDataSnapshot) in
-bunch of code that sets up my post and appends it to an array-
self.collectionView.reloadData()
})
Some of my data structure is :
users
3093098409384
friends
29834098209 : true
posts
099390234
userWhoPosted: 29834098209
So I'm pulling the friends out of the users-> friends -> UID bit, but how do I then get back posts made by those users, and THEN carry out my normal query back I'm doing?
Any guidance is appreciated.
Have a look at this article:
https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html?m=1
Basically you need to "fanout" your data, that means replicating the "post" object data to multiple locations to make it easier to access.
i.e: create a "timeline" mode and under that each user's uid and under that posts from this user's followers.
Timeline: {
<user_uid>: {
<post_id>: {
// your post data
}
}
}
You do that by having each time a user submits a new post, send that post to the timeline of each of his followers.
It may sound strange but Firebase has a concept where you should duplicate data many times to make it easier to access.
I'm using the below code to get the friends list,
let fbRequest = FBSDKGraphRequest(graphPath:"/me/friends", parameters:["fields": "friendlists"]);
fbRequest.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
if error == nil {
print("Friends are : \(result)")
} else {
print("Error Getting Friends \(error)");
}
}
It's always returning empty array.
OutPut:
Friends are : {
data = (
);
}
If I try sending a simple call to /me/friends, FBSDKGraphRequest(graphPath:"/me/friends", parameters:nil) an error logged as below,
FBSDKLog: starting with Graph API v2.4, GET requests for //me/friends should contain an explicit "fields" parameter.
So I referred this answer for the above Parameters.
I authorized the app with two facebook users, both of them are friends in facebook, But I can't see their details in the response.
Still, empty array is returning.
Anyone please check whether the graph path and parameters I mentioned in the code is correct.
The privacy settings in the facebook account for friends list is public.
There is a difference between "friends" and "friendlists". What you want to get is the list of "friends", not the "friendlists". You donĀ“t need the "fields" parameter for that, a simple call to /me/friends is enough.
That being said, you can only get friends who authorized your App too, so if none of your friends authorized your App, you will get an empty array. Of course you need to authorize with the user_friends permission, and your friends must authorize your App with that permission too.
You can get only authorized friends with your application.
Only friends who installed this app are returned in API v2.0 and higher. total_count in summary represents the total number of friends, including those who haven't installed the app.
Check this link for deatiled information.
You can get only count of friends linked to your account, but you can not get any other detail of friends without permission.
I'm new to youtube api v3, and I have a problem when get all my subscribed channel. I've subscribed 65 channel but I can only get 50 each api call. So, Is there any way to get all?
Another thing is, I have a channelID, is there any api to check this channel in a list of my subscribed channel?
Youtube API restricts 50 results per call. In case you were asking whether you can get all 65 in the same call, then the answer is no. However, if you meant whether all 65 can be retrieved then, yes. You'll need to use the nextPageToken paramter value and pass it to the pageToken parameter which will take you to the next page. In code, it can be handled in the following way(as shown in the documentation):
var nextPageToken = '';
// This loop retrieves a set of playlist items and checks the nextPageToken
// in the response to determine whether the list contains additional items.
// It repeats that process until it has retrieved all of the items in the list.
while (nextPageToken != null) {
var playlistResponse = YouTube.PlaylistItems.list('snippet', {
playlistId: playlistId,
maxResults: 25,
pageToken: nextPageToken
});
Regarding your ChannelID problem, from your description I understand you want to check whether you are subscribed to a particular channel in case you have it's ID. I believe the Activities method of Youtube API should be able to help you out. Look at contentDetails.subscription property. I hope that resolves your problem.