This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 16th, 2010  |  syntax: PHP  |  size: 2.14 KB  |  views: 80  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         if ( $post->post_type == 'event' ) {
  2.                 // build the attachment
  3.                 $permalink = apply_filters('sfc_publish_event_permalink',wp_get_shortlink($post->ID), $post->ID);
  4.                 $attachment['name'] = $post->post_title;
  5.                 $attachment['start_time'] = '2010-10-14T21:00:00+0000';
  6.                
  7.                 //Y-m-d\TH:i:sO
  8.                 $eventday =  strftime('%d', get_post_meta($post->ID, '_eventtime', true));
  9.                 $eventmonth = strftime('%m', get_post_meta($post->ID, '_eventtime', true));
  10.                 $eventyear = strftime('%Y', get_post_meta($post->ID, '_eventtime', true));
  11.                 $eventhour = strftime('%H', get_post_meta($post->ID, '_eventtime', true));
  12.                 $eventminute = strftime('%M', get_post_meta($post->ID, '_eventtime', true));
  13.                
  14.                 $attachment['end_time'] = $eventyear.'-'.$eventmonth.'-'.eventday.'T'.$eventhour.':'.$eventminute.':00+000';
  15.                
  16.  
  17.                 if ($options['autopublish_app'] && !get_post_meta($id,'_fb_post_id_app',true) ) {
  18.        
  19.                         if ($options['fanpage']) {
  20.                                 $url = "https://graph.facebook.com/{$options['fanpage']}/events";
  21.                                 $attachment['access_token'] = $options['page_access_token'];
  22.                         }
  23.                         else {
  24.                                 $url = "https://graph.facebook.com/{$options['appid']}/events";
  25.                                 $attachment['access_token'] = $options['app_access_token'];
  26.                         }
  27.        
  28.                         $data = wp_remote_post($url, array('body'=>http_build_query($attachment)));
  29.        
  30.                         if (!is_wp_error($data)) {
  31.                                 $resp = json_decode($data['body'],true);
  32.                                 if ($resp['id']) update_post_meta($id,'_fb_post_id_app',$resp['id']);
  33.                         }
  34.                 }
  35.        
  36.                 // publish to profile
  37.                 if ($options['autopublish_profile'] && !get_post_meta($id,'_fb_post_id_profile',true)) {
  38.        
  39.                         $url = "https://graph.facebook.com/{$options['user']}/events";
  40.        
  41.                         // check the cookie for an access token. If not found, try to use the stored one.
  42.                         $cookie = sfc_cookie_parse();
  43.                         if ($cookie['access_token']) $attachment['access_token'] = $cookie['access_token'];
  44.                         else $attachment['access_token'] = $options['access_token'];
  45.        
  46.                         $data = wp_remote_post($url, array('body'=>http_build_query($attachment)));
  47.        
  48.                         if (!is_wp_error($data)) {
  49.                                 $resp = json_decode($data['body'],true);
  50.                                 if ($resp['id']) update_post_meta($id,'_fb_post_id_profile',$resp['id']);
  51.                         }
  52.                 }
clone this paste RAW Paste Data