RestFB getting Conversations - java

Iam using restfb to get in touch with Facebook from our application.
I have link to the conversation
https://www.facebook.com/prasannapatireddy/posts/234992897106899?comment_id=263969987542523
Now what I need is using above link I have to find out the Attachments if any in this conversation.
How can we do this in Java.
I tried below but didn't work
'
Connection myFeed = facebookClient
.fetchConnection("https://www.facebook.com/prasannapatireddy/posts/234992897106899?comment_id=263969987542523",Comment.class);
Please Help.
Thanks & Regards,
Prasanna

You have to provide the information in your call which fields you need. And you cannot use the perma link of a comment you see on Facebook, this is all about the Graph API.
Connection<Comment> commentConnection = facebookClient.fetchConnettion("<comment_id>",
Comment.class, Parameter.with("fields", "attachment"));
The comment id should be fetched via graph api or with some luck you can try to build it by hand.

Related

Google books api always returns nothing

I am trying to use Google books API but for any request I receive totalItems = 0.
I've tried to send the request in chrome, for example:
https://www.googleapis.com/books/v1/volumes?q=flowers+inauthor:keyes&key=MY_KEY
Also I've tried the approach, described here:
https://github.com/google/google-api-java-client-samples/blob/master/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/BooksSample.java
And for any query with any parameters I always receive nothing:
{
"kind": "books#volumes",
"totalItems": 0
}
I generated key using developer console: https://console.developers.google.com and selected option Api Key.
I will appreciate any help with this issue.
Thanks in advance!
As I've understood, the problem is in my country(Belarus). Looks like Google Books APi doesn't work in Belarus. Problem can be fixed by using VPN.

how do i share a post on facebook using restfb

this is my java code using resfb lib to post something on my facebook groups feed:
FacebookClient fb=new DefaultFacebookClient(token);
FacebookType message=fb.publish(pid+"/feed",FacebookType.class,Parameter.with("message", description));
now what do i do to share posted article?
thanks a lot for your help!
Graph API doesn't provide an explicit share operation, but you can create a post which is a link to another post, which should be displayed as a share. Something like this:
fb.publish("me/feed", FacebookType.class, Parameter.with("link", "https://www.facebook.com/10152237769155733"));

Posting to a wall of a facebook user using the graph api

i am new to facebook app development and i am trying to post a simple text on the wall of the user using the https://graph.facebook.com/me/feed?access_token=ACCESS_TOKEN&message=hello but this does not seem to be working..Any thoughts as to where i might be going wrong?
Check if you have permissions to post from the app.
Add app_id to your call.
If you’re just calling the URL you mentioned, that would be a GET request. To post a message to the user’s wall you have to use method POST. You can test it in the Graph API Explorer – change the method to POST via the dropdown, click „add a field” and use name=message and value=your_message …

How to retrieve home timeline from twitter in the form of .xml or JSON using java?

I want to get a home timeline from twitter and I was able to get the home timeline using twitter4j and oauth authentication method
ConfigurationBuilder confBuilder = new ConfigurationBuilder();
confBuilder.setOAuthAccessToken(accessToken.getToken())
.setOAuthAccessTokenSecret(accessToken.getTokenSecret())
.setOAuthConsumerKey(key)
.setOAuthConsumerSecret(secret);
Twitter twit = new TwitterFactory(confBuilder.build()).getInstance();
User user = twitter.verifyCredentials();
List<Status> statuses = twitter.getHomeTimeline();
but the result is not in the form of .xml or JSON. i also tried
WebResource resource = client.resource("https://api.twitter.com/1/statuses/user_timeline.json");
but all I get is GET https://api.twitter.com/1/statuses/user_timeline.json returned a response status of 401 Unauthorized
I googled many times but I just cant get it right. Please I need a sample java code of how to do it. Complete code that can run right away would be really helpful as I got a lot of partially coded program and just couldnt get it to work. thank you in advance
OK, so after looking at the release notes for the 2.2.x versions, it appears there is a way to get the JSON representation from Twitter4J, but it's disabled by default since it uses some extra memory.
So, you need to:
Enable the JSONStore using the jsonStoreEnabled config option
Get the JSON representation of a request using the getRawJson method
Sorry there's no code example, I haven't tried it myself.
401 Unauthorized:
Authentication credentials were missing or incorrect.
You need to authenticate before you perform the query.

Is there any way of changing gmail password programmatically using java?

Is there any way of changing gmail password programmatically using java?
The google provisioning API guide has updateUser method which takes a UserEntry object. You can use it to update the password I suppose, you will have to try it out. Check the javadocs for definition of UserEntry
I would have been very surprised if you could, and it doesn't look like it.
This page shows you the list of settings you can change in the Google Apps "Email Settings API", and change-password isn't there.
http://code.google.com/googleapps/domain/email_settings/developers_guide_protocol.html#GA_email_settings_api_ops
HTH
I think yes. You can record all operation with web pages by Selenium, test if all ok, and after export to java code - only problem can arise if Google will use CAPCHA
Uh, just use an http client to post this web page: https://www.google.com/accounts/b/0/EditPasswd. Use http://hc.apache.org/httpclient-3.x/ or something similar. You'll need to keep track of cookies properly, so google thinks you are logged in when you load the page. But yeah, obviously it is possible. If your browser can do it, you can do it programmatically through sending http requests. If you want to be double careful, you can use something like tamperdata in firefox to sniff exactly what your browser sends when you request a password change, so you don't miss any silent fields or whatnot.
Using Google Provisioning API, to change the password, you have to set it to login attribute of UserEntry object:
import sample.appsforyourdomain.AppsForYourDomainClient;
...
AppsForYourDomainClient client = new AppsForYourDomainClient(email, password, domain);
UserEntry user = client.retrieveUser("username");
user.getLogin().setPassword("newpassword");
client.updateUser("username", user);

Categories