Hello
I have one problem i'm trying to make wen some one view a node to get popup to allow him to publish node what he view to the wall...
the ability to publish to wall wen editing or adding node works perfectly even publishing to application profile page...

Comments

Spiroc’s picture

Ok to every one who like this i manage to do this whit the Rule module here is example rule how to do it

array (
  'rules' => 
  array (
    'rules_testrule1' => 
    array (
      '#type' => 'rule',
      '#set' => 'event_node_view',
      '#label' => 'Testrule1',
      '#active' => 0,
      '#weight' => '0',
      '#categories' => 
      array (
        0 => 'example',
      ),
      '#status' => 'custom',
      '#conditions' => 
      array (
        0 => 
        array (
          '#type' => 'condition',
          '#settings' => 
          array (
            'type' => 
            array (
              'blog' => 'blog',
            ),
            '#argument map' => 
            array (
              'node' => 'node',
            ),
          ),
          '#name' => 'rules_condition_content_is_type',
          '#info' => 
          array (
            'label' => 'Viewed content is Blog entry',
            'arguments' => 
            array (
              'node' => 
              array (
                'type' => 'node',
                'label' => 'Content',
              ),
            ),
            'module' => 'Node',
          ),
          '#weight' => 0,
        ),
      ),
      '#actions' => 
      array (
        0 => 
        array (
          '#weight' => 0,
          '#info' => 
          array (
            'label' => 'Execute custom PHP code',
            'module' => 'PHP',
            'eval input' => 
            array (
              0 => 'code',
            ),
          ),
          '#name' => 'rules_action_custom_php',
          '#settings' => 
          array (
            'code' => '      $attachment = array(
        \'name\' => $node->title,
        \'href\' => url(\'node/\' . $node->nid, array(\'absolute\' => TRUE, \'fb_canvas\' => TRUE)),
        \'description\' => strip_tags($node->teaser),
        \'media\' => array(array(\'type\' => \'image\', \'src\' => url(($node->field_slika[0][\'filepath\']), array(\'absolute\' => TRUE)), \'href\' => url(\'node/\' . $node->nid, array(\'absolute\' => TRUE, \'fb_canvas\' => TRUE)))),

      );

      $user_message = t(\'Check out my latest Blog on !site...\',
                        array(\'!site\' => variable_get(\'site_name\', t(\'my Drupal for Facebook powered site\'))));
      $actions = array();
      $actions[] = array(
        \'text\' => t(\'Read more\'),
        \'href\' => url(\'node/\' . $node->nid, array(\'absolute\' => TRUE, \'fb_canvas\' => TRUE)),
      );
      fb_stream_publish_dialog(array(\'message\' => $user_message,
                                     \'attachment\' => $attachment,
                                     \'action_links\' => $actions,
                               ));',
            'vars' => 
            array (
              0 => 'node',
              1 => 'user',
            ),
            '#eval input' => 
            array (
              'rules_input_evaluator_php' => 
              array (
                'code' => 
                array (
                  0 => 'node',
                  1 => 'user',
                ),
              ),
              'token_rules_input_evaluator' => 
              array (
                'code' => 
                array (
                  0 => 'node',
                ),
              ),
            ),
          ),
          '#type' => 'action',
        ),
      ),
      '#version' => 6003,
    ),
  ),
)

and now i have one more little problem i use custom field named slika to pull the image used on the blog entry and wen i stream post from my web it's ok the fb_stream_publish_dialog pull the image from right location but wen i use from the canvas application try to pull the image from the http://example.com/fb_cb/appsecretkey/sites/default/files/image.jpg any help how to remove this /fb_cb/appsecret or how to rewrite

'media' => array(array('type' => 'image', 'src' => url(($node->field_slika[0]['filepath']), array('absolute' => TRUE)), 'href' => url('node/' . $node->nid, array('absolute' => TRUE, 'fb_canvas' => TRUE)))),

to get the corect location of the image wen in publish to wall from the canvas application?

Dave Cohen’s picture

Try setting the option 'fb_canvas'=>FALSE on the image src.

Spiroc’s picture

That don't help it's same.

Spiroc’s picture

Ok i fix it :) so the code is


'media' => array(array('type' => 'image', 'src' => url($GLOBALS['base_url'] . '/' .$node->field_slika[0]['filepath']), 'href' => url('node/' . $node->nid, array('absolute' => TRUE, 'fb_canvas' => TRUE)))),
HS’s picture

I'm trying to achieve the same functionality, where when a user reads an article (or views any specified content type) it publishes to their stream and wall.

How is this achieved? Any help is appreciated.

Dave Cohen’s picture

Version: 6.x-3.0-rc7 » 6.x-3.x-dev

fb_stream.module will soon have helpers for posting to walls. Please review patch: #1454736: Post Content to Facebook Page using fb_stream.module

fb_graph.module has helpers for publishing to timeline. It's kind of a complicated mess to register timeline actions. When you submit the action, its likely to be rejected if its not obvious to a user exactly when something is being published to their timeline.