Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Created March 27, 2013 03:32
Show Gist options
  • Save LinzardMac/5251391 to your computer and use it in GitHub Desktop.
Save LinzardMac/5251391 to your computer and use it in GitHub Desktop.
if(count($parsed_response->feed->data)>0) {
## Now, after we've already used the empty variable $max_id
# $max_id = $parsed_response->statuses->data[0]->updated_time;
//echo "The max_id_str should be : " . $parsed_response->max_id_str;
$max_id = date("Y-m-d\TH:i:s\Z", strtotime($parsed_response->feed->data[0]->created_time));
update_option('fbp_max_status_id', $max_id);
echo $max_id;
// print_r($parsed_response->statuses->data);
$statusesray = $parsed_response->feed->data;
// var_dump($statusesray);
foreach($statusesray as $status)
{
if($status->type=='status')
{
// Parse the status's timestamp
$gmt_date = date('Y-m-d H:i:s', strtotime($status->created_time));
$post = array(
'post_content' => $status->message,
'post_type' => 'imported_content',
'post_title' => __('status', 'fbp').'-'.$status->id,
'post_status' => 'publish',
'post_date_gmt' => $gmt_date,
'post_date' => get_date_from_gmt($gmt_date),
'post_author' => $author->ID,
);
$post_id = wp_insert_post($post);
set_post_format($post_id , 'status');
wp_set_post_terms( $post_id, $statusidstring, 'post_tag', false ) ;
wp_set_post_terms( $post_id, 4, 'category', false ) ;
//update_post_meta( $post_id, 'status_link', $status->id);
// update_post_meta( $post_id, 'status_author', $status->from_user);
$goodstatid = str_replace( $status->from->id.'_', "", $status->id);
update_post_meta( $post_id, 'tweet_url', 'http://facebook.com/' . $pageid . '/posts/'.$goodstatid.'');
} else {
echo 'There are no new statuses';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment