You are here

function social_content_instagram_post_callback in Social Content 7

1 string reference to 'social_content_instagram_post_callback'
social_content_instagram_social_content_info in modules/instagram/social_content_instagram.module

File

modules/instagram/social_content_instagram.module, line 170
Social Content: Instagram module.

Code

function social_content_instagram_post_callback(&$wrapper, $post, $external_id, $settings) {
  $wrapper->created
    ->set($post->created_time);
  $body_text = isset($post->caption) ? $post->caption->text : '';
  $body_text = social_content_validate_text($body_text);
  $wrapper->body
    ->set(array(
    'value' => $body_text,
    'format' => 'filtered_html',
  ));
  if (!isset($post->images->standard_resolution->url)) {
    watchdog('social_content_instagram', 'Missing image url on Instagram Import', WATCHDOG_WARNING);
    return FALSE;
  }
  $image_url = $post->images->standard_resolution->url;
  $image_field_name = 'field_instagram_picture';
  $image_file = social_content_get_image_file($image_url, $image_field_name, $settings['min_resolution']);
  if (!$image_file) {
    return FALSE;
  }
  $wrapper->{$image_field_name}
    ->set($image_file);
  $wrapper->field_instagram_link
    ->set(array(
    'url' => $post->link,
  ));
  return TRUE;
}