Function Reference: gdfi_fb_post

Summary

This function has not been documented yet.

Source Code

function gdfi_fb_post($msg = '', $link = '') {
    global $wpdb;
    $gdfi_config = get_option('gdfi_config');
    $page_at = gdfi_get_fb_page_accesstoken();
    if (!isset($gdfi_config['app_page_post']) || $gdfi_config['app_page_post'] == '') {
        return;
    }// if not fb page to post to bail.
    if (!isset($page_at) || $page_at == '') {
        return;
    }// if not fb page access token bail.

    $url = 'https://graph.facebook.com/' . $gdfi_config['app_page_post'] . '/feed';

    $args = array();

    $args['body']['access_token'] = $page_at;
    $args['body']['message'] = $msg;
    $args['body']['link'] = $link;
    $args['timeout'] = 30;

    $result = wp_remote_post($url, $args);
    if (is_wp_error($result)) {
        return false;
    } else if ($result['response']['code'] == '200') {
        return true;
    }
}