I haven't been able to find how to shorten a URL with or without the Shorten URLs module, at least in the context of creating a Twitter action that is triggered when a new story is created. Is this documented somewhere? I haven't seen it in the information for the Twitter module, or in the UI for the module itself (where certain available tokens are listed).

Thanks!

Comments

ts404’s picture

Hi m8,

Modify the file %modules%/twitter/twitter_actions/twitter.module

At the end of file, replace

// Node-based variable translation is only available if we have a node.
  if (isset($node) && is_object($node)) {
    $variables = array_merge($variables, array(
        '%uid' => $node->uid,
        '%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
        '%node_type' => node_get_types('name', $node),
        '%title' => $node->title,
        '%teaser' => $node->teaser,
        '%body' => $node->body
      )
    );
  }

by

// Node-based variable translation is only available if we have a node.
  if (isset($node) && is_object($node)) {
    $variables = array_merge($variables, array(
        '%uid' => $node->uid,
        '%node_url' => twitter_shorten_url(url('node/'. $node->nid, array('absolute' => TRUE))),
        '%node_type' => node_get_types('name', $node),
        '%title' => $node->title,
        '%teaser' => $node->teaser,
        '%body' => $node->body
      )
    );
  }

Bye ;)

abraham’s picture

Status: Active » Fixed

Twitter will also auto shorten links that are to long.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.