When adding a post programmatically how can i get it to trigger the auto publish Facebook plugin

Hello

I have bought ultimate facebook and it works fine when i add posts through the admin panel. However sometimes I add posts programmatically and I would still like to be able to trigger the facebook plugin to add these posts to facebook. Please can you advise if this is possible. If have ran some code which inserts posts programmatically and it doesnt add the posts to my facebook account. Please could you provide an example of a link to the appropriate API functions.

Thanks a lot

Please copy any reply to andrea@redboxmail.com

  • Rob

    Hi

    I dont think our code could be attached to any specific wordpress hook as we use an import routine outside of wordpress to insert posts manually

    so the code is like this

    mysql_query("INSERT INTOwp_postsSETpost_title`='".$disp_address."',
    post_content='".mysql_real_escape_string($desc)."',
    post_status='publish',
    post_date= NOW(),
    post_date_gmt= NOW(),
    comment_status='closed',
    ping_status='closed',
    post_name='".str_replace(array(' ', ','), array('-', ''), strtolower($disp_address))."',
    post_parent='0',
    post_type='listing',
    post_lat='".$lat."',
    post_long='".$long."'
    ");`

    I imagine the plugin works such that when a post is created it is hooked into some event which triggers the plugin to post it on facebook. A workaround for us would be to modify the plugin such that is publishes the post on facebook when the post is updated rather than created. It doesnt matter if it creates a new post everytime the post is updated.

    Thanks in advance for your help

  • Vladislav

    Hello,

    The plugin was written to be executed in the WordPress context, and can't really be reliably used outside of it. One way of dealing with this would be to use the Facebook PHP SDK and Graph API calls directly in your surrounding (ie. non-WP) PHP code.

    However, the very approach of creating a post in a direct sql query is not the greatest one as it's *quite* fragile, not future-safe and will break all kinds of plugin integration (as it does with our plugin in this example). A better approach might be to write a bridge plugin that could be triggered with some way from your surrounding PHP and publish the post using regular WP API calls. An even better approach could use something like WordPress XML-RPC API or JSON API to publish your post, which would also automatically take care of Facebook publishing (and many other potential integration issues).

  • Vladislav

    Basically, depending on the context, the plugin publishing will get triggered on WordPress save_post or post_updated hook so, within the WordPress context, pushing on updates should work. Having said that, on post update the publishing method will also check the old post's status and give up on further processing if the post has already been published (to prevent potential issues in edge cases such as, say, minor fixes on old posts). In this case, you may want to set the wdfb_metabox_publishing_publish value in the POST array to 1, which will force the update to be published. I hope this helped. If neither of those didn't seem to help, it'd mean a lot to me to know exactly how you ended up implementing the bridge so I can be of a bit more immediate help

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.