if ( $post->post_type == 'event' ) { // build the attachment $permalink = apply_filters('sfc_publish_event_permalink',wp_get_shortlink($post->ID), $post->ID); $attachment['name'] = $post->post_title; $attachment['start_time'] = '2010-10-14T21:00:00+0000'; //Y-m-d\TH:i:sO $eventday = strftime('%d', get_post_meta($post->ID, '_eventtime', true)); $eventmonth = strftime('%m', get_post_meta($post->ID, '_eventtime', true)); $eventyear = strftime('%Y', get_post_meta($post->ID, '_eventtime', true)); $eventhour = strftime('%H', get_post_meta($post->ID, '_eventtime', true)); $eventminute = strftime('%M', get_post_meta($post->ID, '_eventtime', true)); $attachment['end_time'] = $eventyear.'-'.$eventmonth.'-'.eventday.'T'.$eventhour.':'.$eventminute.':00+000'; if ($options['autopublish_app'] && !get_post_meta($id,'_fb_post_id_app',true) ) { if ($options['fanpage']) { $url = "https://graph.facebook.com/{$options['fanpage']}/events"; $attachment['access_token'] = $options['page_access_token']; } else { $url = "https://graph.facebook.com/{$options['appid']}/events"; $attachment['access_token'] = $options['app_access_token']; } $data = wp_remote_post($url, array('body'=>http_build_query($attachment))); if (!is_wp_error($data)) { $resp = json_decode($data['body'],true); if ($resp['id']) update_post_meta($id,'_fb_post_id_app',$resp['id']); } } // publish to profile if ($options['autopublish_profile'] && !get_post_meta($id,'_fb_post_id_profile',true)) { $url = "https://graph.facebook.com/{$options['user']}/events"; // check the cookie for an access token. If not found, try to use the stored one. $cookie = sfc_cookie_parse(); if ($cookie['access_token']) $attachment['access_token'] = $cookie['access_token']; else $attachment['access_token'] = $options['access_token']; $data = wp_remote_post($url, array('body'=>http_build_query($attachment))); if (!is_wp_error($data)) { $resp = json_decode($data['body'],true); if ($resp['id']) update_post_meta($id,'_fb_post_id_profile',$resp['id']); } }