How do I post to my fb page from code

Hi,

I am building wp<-> fb application.

In this site fb users registers to my site with single login, and after they play “real” game, the admin posts on there behalf the number of points they got.

Now,I need that in some cases ( e,g, player X got more then 100points)

the Admin will post automatically (on fb) “Player X got more then 50 points”.

With mentioning the name of player X on facebook.

The question is,

Is there a simple API of the plugin that I can use for that issue?

Thanks,

Koff

  • Vaughan
    • Support/SLS MockingJay

    hiya

    thanks for the post.

    I’m not sure I understand what you are asking.

    The plugin will post comments & posts to Facebook.

    so unless you made a comment or post with a post title & post content, i’m not sure it will work.

    how is your points system integrated? there pretty much has to be a post made for it to work.

    I will flag the developer for you, but I think this will require a bit of custom coding in order to achieve as I don’t think it’s within the scope of the plugin to be used like you are wanting. i may be wrong however. if you could give a bit more insight into how the game integrates with wordpress & so on.

    hope this helps somewhat.

    thanks.

  • koff
    • Site Builder, Child of Zeus

    Hi,

    Thanks for the prompt answer,

    I would like on a certain events ( I will take care of it) to post to FB from code.

    Extra coding is not a problem, I just wanted to know of I can use the plugin API to do this. ( I guess that exactly what happens in the plugin on publish_post hook )

    I hope the question is clearer now,

    Thanks,

    Koff

  • Vladislav
    • Dead Eye Dev

    Hello,

    Thanks for the additional explanation. The class Wdfb_Model comes with a post_on_facebook() method which you can hopefully use for this purpose. The parameters the method takes are 1) the target (notes, events or feed, feed is the most likely value you’d want to use), 2) the Facebook identity you wish to post to (you can use the get_current_user_fb_id() method from the same class to obtain the current user’s associated FB identity) and, lastly, the post hash – an associative array of what to actually post to Facebook. The hash members are dependent on the target (i.e. different for, say, event and feed post – you may want to check the “Arguments” column in the table here: https://developers.facebook.com/docs/reference/api/publishing/ ). The class is located in the lib/class_wdfb_model.php file and if your code is triggered on or after plugins_loaded it should be automatically loaded for you.

  • koff
    • Site Builder, Child of Zeus

    Great!!!

    That’s exactly the answer I was looking for.

    I got two more questions though:

    1. I guess I need the user extended permissions to post on his feed.

    The Question is,can I ask for this permission on the registratoon?

    2. Can I mention a user in some way?(e.g. @user_name )

    Thanks again,

    Koff

  • Vladislav
    • Dead Eye Dev

    Hi,

    If your users are registering/logging in with Facebook, you can influence the permissions asked from them using one of these filters: “wdfb-permissions-new_user” (this is the basic set of permissions asked typically on registration or login), “wdfb-permissions-non_publisher” (additional permissions asked from your users that won’t be publishing posts but will, for an example, make use of albums and such), and “wdfb-permissions-publisher” (highest level of requested privileges). As for the mentioning the users, perhaps this can help: https://developers.facebook.com/docs/opengraph/guides/tagging/ (there’s a subsection titled “Mentioning friends” a bit down the page).

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.