My favorites | Sign in
Project Home Downloads Wiki Issues Source
Updated May 16, 2011 by

API Calls / Examples


// Objects
JsonObject user             = FbGraph.getObject("btaylor");
JsonObject page             = FbGraph.getObject("cocacola");

// Connections
JsonArray friends           = FbGraph.getConnection("me/friends");
JsonArray newsFeed          = FbGraph.getConnection("me/home");

// Selection
JsonObject fields           = FbGraph.getObject("bgolub", Parameter.with("fields", "id,name,picture").parameters());
JsonElement ids             = FbGraph.api("", Parameter.with("ids", "arjun,vernal").parameters());

// Picture
String profilePicUrl        = FbGraph.getPicture("me");

// Paging
JsonArray filteredLikes     = FbGraph.getConnection("me/likes", Parameter.with("limit", "3").parameters());
JsonArray filteredSearch    = FbGraph.getConnection("search", Parameter.with("until", "yesterday").and("q", "orange").parameters());


// Public search
JsonArray publicPostSearch  = FbGraph.getConnection("search", Parameter.with("q", "watermelon").and("type", "post").parameters());
JsonArray publicUserSearch  = FbGraph.getConnection("search", Parameter.with("q", "mark").and("type", "user").parameters());


JsonElement post            = FbGraph.publish("me/feed", Parameter.with("message", "Hello World!").parameters());


Boolean deleted             = FbGraph.delete("OBJECT_ID");


JsonArray data              = FbGraph.getConnection("APP_ID/insights");
Comment by, May 6, 2011

Can you share an example for a complete controller ?

Would you inherit the module or import it into the controller ?

Comment by project member, May 16, 2011
// [...]
import play.modules.facebook.FbGraph;
import play.modules.facebook.FbGraphException;
import play.modules.facebook.Parameter;
// [...]
public class Application extends Controller {
// [...]
    public static void facebookLogin() {
        try {
            JsonObject profile = FbGraph.getObject("me"); // fetch the logged in user
            String email = profile.get("email").getAsString(); // retrieve the email
            // do useful things
            Session.current().put("username", email); // put the email into the session (for the Secure module)
        } catch (FbGraphException fbge) {
            if (fbge.getType() != null && fbge.getType().equals("OAuthException")) {
// [...]
Comment by, May 22, 2012

the module facebook is not avialable in my app, am I doing somethig wrong?

Comment by, Jun 1, 2012

Is this compatible with Play 2.0?

Comment by project member, Jun 12, 2012

No, the module is compatible with Play 1.2.x.

Play 1.2 and Play 2.0 are two different beasts.

Comment by, Sep 10, 2012

I want to upload a photo, I'm doing that:

JsonElement? post = FbGraph.publish("me/photos", Parameter.with("image", "/home/getho/Escritorio/imagenLarga.jpeg").with("message", "Mi primera foto").parameters());

But I get this error:

HttpResponse?: 400: {"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}

I think that I have to configure the call with this: 'fileUpload' => true but I don't know where can i config this in FbGraph module.


Comment by, Feb 10, 2013

Is version 0.6 compatible with Play 1.2.5? Or do I have to use the version (0.4) found on the play modules site?

Comment by project member, Feb 28, 2013

Yes, version 0.6 is compatible with play 1.2.5.

Comment by project member, Feb 28, 2013


If you need access more information (or publish data), such as the user's birthday or wall, you must request permissions. You can do this by adding the permissions you need to the scope attribute of the <fb:login-button> (e.g. scope="email,user_birthday,read_stream,publish_stream").

Sign in to add a comment
Powered by Google Project Hosting