Twitter4j - Build a graph composed by tweets and their respectives retweets - twitter4j

I need to build a graph in which some nodes are tweets and others are retweets which point to their respective tweets. I start my application doing a search for some subject, let's say "computer". Then, I gather some number of tweets that contains that subject. From there, I want to search for the retweets of these tweets and then, build my network by linking ones to the others.
The problem is that when I try to search for retweets of a tweet using its id, the application throws an exception saying that authentication credentials are missing. Is there a way of getting these retweets without requiring external authentication ('cause my app is not interactive), I mean, is it possible that I can get these information only with my credentials (login,password)?
Maybe that's a silly question I've asked about, but since I'm a beginner at this API and Twitter as well, any help is appreciated.

using Twitter4J? try invoking getReTweets() method. More documentation here.

Read carefully point Number 7 in samples here. Authentication credentials means there are 4 Strings. Two of your application(consumer keys) and Two of the user(access Tokens) using application.

Related

How to retrieve multiple user account details through their Facebook IDs in graph API?

This could be a duplicate of here and here, but can some one provide a complete working example for following.
I have set of different Facebook account Ids, and i need to get the respective account details(user name etc) from these account ids. I need to send a Batch Request for Graph API. Something as follows,
(https://graph.facebook.com?ids=user1, user2, user3,...)
Is this possible as pure HTTP GET request ?
I am using Facebook SDK with Android for the moment. I have gone through the API doc but unable to build the required query yet. Please help.
Maybe post a snippet of your code so we can try to solve your problem better. With the info you provided, the URL https://graph.facebook.com/?ids=user1,user2,user3 works just fine and returns 3 users.
The URL format looks correct. Keep in mind the total character limit, but otherwise I suspect you are stuck in a different place (e.g. sending the query or saving the result).

How does the Facebook Graph API public post searching works?

I've started working with Facebook Graph API this month and I'm currently experiencing some odd behaviors with it.
To start, I'm using the Graph API 1.0 (which supports public post searching), with queries such as those below.
https://graph.facebook.com/v1.0/search?q=foo bar&type=post
https://graph.facebook.com/v1.0/search?q=foo&type=post
The weird behavior in this case is that the first query returns almost the same number of results that the second one. Thus, no matter how "vague" my query is, I'm getting a limited number of posts (yeah, I'm already considering pagination).
So how does this work? The Graph API Documentation isn't clear about this subject, so any clarification would be really appreciated.
As I understood so far, Facebook does not return all public posts containing the researched terms. Some old questions here in StackTrace support this assumption (example)
Different apps or different users may retrieve different results (which is another "odd" behavior I found). (example)
Am I correct? If so, is there ANY way to improve my recall? Any paid services from Facebook or specific permissions that I should get for my app? Searching from multiple views (users or apps) would help? Is there any way to query only recent results and therefore obtain more results?
Thank you.
P.S.: I'm aware that Facebook has been planning to remove this functionality by 2015, but for now it's working and I wanted to give a try :-)

To Search Universal Tweets Via Twitter API v1.1

Hi this might eventually turn out to be a stupid question but i'd rather ask!! Its regarding GET search/tweets Twitter API v1.1. As documented by Twitter this particular API is designed to accept numerous parameter against which a search is performed and tweets are returned. One of these parameters is "geocode" which accepts value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers) https://dev.twitter.com/docs/api/1.1/get/search/tweets.
Its quite alright if is set those parameter values.
My question is since it is "geocode" optional will not setting them return me universal tweets? or is there any other way I could find universal tweets using GET search/tweets Twitter API v1.1.
Also, Ive tried Streaming API POST statuses/filter with very indifferent/unsatisfactory results
P.S As per requirement of my app I need to search apps both universally and locally, as per users choice.
It seems if you skip the "geocode" parameter, Universal Tweets are returned!!

How can one learn to use the twitter API?

Ok before you jump to some conclusion like I'm looking for a free lunch or something of the sort, read the description entirely.
I have experience only in making small simple apps in PHP, Java and ASP.NET. I had no idea what GET, SET etc exactly are and what REST services are. To try to use the Twitter API, I did some reading and got to know (I might be wrong here, because this is what I THINK that I know..) that you can make a GET request like this one:
http://api.twitter.com/1/statuses/user_timeline.json
Using, say, cURL (I haven't tried it yet), and you get a JSON object returned which contains the statuses on your timeline in a certain format. And I verified this from here
But I don't understand how does Twitter know that it is ME and return only MY data? Where am I sending my account details?
What I want is for the use to come to my website, click a button to give my application the permission to access his/her Tweets and I do some processing in PHP and display the output. But I don't know where do I start from?
I am not asking you to give me bread, I'm asking you to tell me what should I do to learn to fish?
All tutorial I have been following till now have been sort of spoon fed where they say things like 'Download this php file from our site, include it in your source file, use this method to do this and that method to do that.'
This one is a change for me, so does anyone have any pointers? Is there any reading that I should do or approach that I must follow to learn that I'm doing wrong?
EDIT : I know there are 3rd party libraries out there and it might be easier to learn to use those, but I want to have an idea of how the people who made those did it.
To use Twitter (at least its REST API), you had better to read tutorials about the following things :
REST architecture because it is how Twitter communicates with your application.
HTTP requests. Useful for Authentication of requests (HTTP headers), kinds of HTTP requests (GET and POST for the Twitter API) and return codes of requests.
OAuth which is the protocol used by Twitter for authenticating requests.
Format of datas returned by Twitter after the requests. Most of the time it is JSON but it can also be like in a URL query string (for OAuth authentications). You are lucky because before there were XML and Atom (for RSS feeds) too.
And of course the Twitter Documentation to know how they use all that stuff, how they know that is YOU with THIS application (request authentications) and to know the objects manipulated by the API (mainly tweets, users and timelines).
Good luck for it !

Read my Facebook application's publish stream posts

I created a number of posts on behalf of the user by issuing an HTTP POST request to (PROFILE_ID/feed) with the publish_stream. Sample:
https://graph.facebook.com/me/feed?
I got everyone's post ids, but I when I'm trying to access and read them I getting a "false" respond..
I was at a Perl Mongers meeting (Los Angeles) last week where the presentation was on integration with Facebook. In particular, one of the developers was discussing his new module, Facebook::Graph. He indicated that in producing the module he learned a lot about what Facebook would do if you request information but don't provide everything it is expecting in your request. Your problem description sounds like a case in point.
The module's description is:
This is a Perl interface to the Facebook Graph API
http://developers.facebook.com/docs/api. With this module you can
currently query public Facebook data, query privileged Facebook data,
and build a privileged Facebook application. See the TODO for all that
this module cannot yet do.
There is a companion POD for that module called Facebook::Graph::Cookbook. It contains a couple of cookbook examples.
While the module is still fairly new and under development, I know that the individual who worked on it has spent many hours working on it in a professional setting where solid results are expected. I'm confident that he "got it right." It's currently being used by a high-traffic well known website.
There's no point trying to re-implement interfacing with this API when someone else has done a good job of it already. Through the discussion that took place after the presentation I know that the module has gone through extensive testing. That's not to say it's perfect, but it's probably a hundred or more man-hours further along the journey.
It's my suggestion that you implement your Facebook Graph interactions through using this module. I suspect when you do, many of your headaches will go away.
You'll need to ask for the read_stream permission to do this