Hey,

first I want to thank you for this great piece of work. I really like this module and I am sure a lot of people are thankful to have facebook integrated just like a piece of cake.

Everything works fine for me, except one tiny little feature, I want to modify: Is it possible to change the contents which are posted to facebook through the stream submodule? It would be really important for my concept, that not only a link and some text is posted, but also a picture, which is a field within the node type, that should be posted.

I guess the answer or workaround lies within the fbconnect_stream_publish.module – but I am not sure how and where I can solve this.

It must be something like....
'media' => array(array('type' => 'image', 'src' => $url_img, 'href' => $lnk_img)));
I reckon, but it won't work. Could you help me or at least give me a hint, how this could work?

Thanks in advance and many greetings from Germany,
Maria

Comments

Miquel Carol’s picture

Assigned: Unassigned » Miquel Carol
Status: Active » Needs work

Hi Maria,

I patched the stream module to show node images on streams. Only need to edit fbconnect_stream_publish.module.
For images on create content:
On line 38 change:

    $_SESSION['fbconnect_feed'] = array(
      'type'    => 'node',
      'title'   => $node->title,
      'nodeurl' => url('node/' . $node->nid, array('absolute' => TRUE)),
    );

To:

    $_SESSION['fbconnect_feed'] = array(
      'type'    => 'node',
      'title'   => $node->title,
      'nodeurl' => url('node/' . $node->nid, array('absolute' => TRUE)),
      'media'   => array(array('type' => 'image', 'src' => $url_img, 'href' => $lnk_img))),
    );

For images on comments:
On line 158 change:

    $feed = array(
      'type'    => 'comment',
      'comment' => $form_state['values']['comment'],
      'title'   => $node->title,
      'nodeurl' => url('node/' . $node->nid, array('absolute' => TRUE)),
    );

To:

    $feed = array(
      'type'    => 'comment',
      'comment' => $form_state['values']['comment'],
      'title'   => $node->title,
      'nodeurl' => url('node/' . $node->nid, array('absolute' => TRUE)),
      'media'   => array(array('type' => 'image', 'src' => $url_img, 'href' => $lnk_img))),
    );

Them on attachment array on case 'coment', only need to add 'media' => $feed['media'], on each case, for example on coment i changed:

      $attachment = array(
        'name'        => $feed['title'],
        'href'        => $feed['nodeurl'],
        'caption'     => t("{*actor*} commented at !site", array("!site" => $site)),
        'description' => strip_tags($feed['comment']),
      );

To

      $attachment = array(
        'name'        => $feed['title'],
        'href'        => $feed['nodeurl'],
        'caption'     => t("{*actor*} commented at !site", array("!site" => $site)),
        'description' => strip_tags($feed['comment']),
        'media'       => $feed['media'],
      );

This modification works fine on my sites. (Facebook need to see the image, not work on sites with private images)
Of course u need to define better $url_img and $lnk_img with drupal variables. I used a imagefield and the node id to automatize the streams. ;)

core44’s picture

Hi Miquel, thanks for the code examples. Would you be able to show me the line to add if I wanted to post the body, or perhaps a basic CCK text field? Thanks again.

core44’s picture

Just to report back to anyone with limited experience like myself. I achieved including the body text by adding in the line for 'body' as below. I was having issues as facebook doesn't allow HTML via the stream, so I needed to include strip_tags().

Hope this helps someone.

$_SESSION['fbconnect_feed'] = array(
      'type' => 'node',
      'title' => $node->title,
      'description' =>  strip_tags($node->body),
      'nodeurl' => url('node/' . $node->nid, array('absolute' => TRUE)),
      );
Miquel Carol’s picture

Hi filthtpixel,

Usually my node->body are too extensible to looks well on fb_streams. I used on your case:

'description' => strip_tags($feed['teaser']),

Surelly looks like better and only need to use the drupal break line to control the description that you stream. ;)

Can see a sample od fb_streams on the fanpage as I use to test the code.
http://www.facebook.com/blog.miquel