You are here

function social_content_twitter_post_callback in Social Content 7

1 string reference to 'social_content_twitter_post_callback'
social_content_twitter_social_content_info in modules/twitter/social_content_twitter.module

File

modules/twitter/social_content_twitter.module, line 170
Social Content: Twitter module.

Code

function social_content_twitter_post_callback(&$wrapper, $post, $external_id, $settings) {

  // No retweets.
  // TODO: Support retweets via setting options.
  if (isset($post->retweeted_status)) {
    return FALSE;
  }
  $wrapper->created
    ->set(strtotime($post->created_at));
  $body_text = social_content_validate_text($post->text);
  $filter = filter_format_exists('tweet') ? 'tweet' : 'filtered_html';
  $wrapper->body
    ->set(array(
    'value' => $body_text,
    'format' => $filter,
  ));
  $tweet_url = 'http://twitter.com/' . $post->user->screen_name . '/status/' . $post->id_str;
  $wrapper->field_tweet_link
    ->set(array(
    'url' => $tweet_url,
  ));
  $wrapper->field_tweet_user
    ->set($post->user->screen_name);
  if ($settings['import_image']) {
    $image_field_name = 'field_tweet_user_picture';
    $image_file = social_content_get_image_file($post->user->profile_image_url, $image_field_name);
    $wrapper->{$image_field_name}
      ->set($image_file);
  }
  return TRUE;
}