The purpose of this post is to show how to link a dailymotion video rss feed to your twitter account using Codebird php, so when the script runs it adds one video post to your twitter account.. can then be run via a cron setup (won’t cover here as system dependent – windows v linux servers).

You need three things sorted out first..

(1) Down the codebird for php library from

(2) Obtain a twitter developer api key details from (best to log into your twitter account first)

(3) Have a Dailymotion rss feed – usually of format[daily motion user name] – where [daily motion user name] is your user account name of account.

The code looks like the following.. things to replace are in [] brackets.

Note: I have taken out my code for shortening links and auto hash tagging using str_ireplace(), but the principles here should get you in the right direction.

require_once("codebird.php"); // reference the codebird php library file (downloaded in step one above)

class BlogPost
    var $date;
    var $ts;
    var $link;
    var $title;
    var $text;

class BlogFeed
    var $posts = array();

    function __construct($file_or_url)
        $file_or_url = $this->resolveFile($file_or_url);
        if (!($x = simplexml_load_file($file_or_url)))  {

        foreach ($x->channel->item as $item)

            $post = new BlogPost();
            $post->date  = (string) $item->pubDate;
            $post->ts    = strtotime($item->pubDate);
            $post->link  = (string) $item->link;
            $post->title = (string) $item->title;

            $post->text = ""; // not using this for tweets

            $this->posts[] = $post;

    private function resolveFile($file_or_url) {
        if (!preg_match('|^https?:|', $file_or_url))
            $feed_uri = $file_or_url;
            $feed_uri = $file_or_url;

        return $feed_uri;

    private function summarizeText($summary) {
        $summary = strip_tags($summary);

        // Truncate summary line to 100 characters
        $max_len = 100;
        if (strlen($summary) > $max_len)
            $summary = substr($summary, 0, $max_len) . '...';

        return $summary;

// read in posts

$ps = new BlogFeed("[daily motion user name]"); // your dailymotion rss feed (step three above)

$posts = $ps->posts;

if($link!="") {

$message = $title." ".$link; // note that the twitter 140 character limit applies to the total of message sent

// now tweet - [] key information unique to twitter account - obtain keys via (step two above)

\Codebird\Codebird::setConsumerKey('[YOURKEY]', '[YOURSECRET]');
$cb = \Codebird\Codebird::getInstance();
$cb->setToken("[YOURTOKEN]", "[YOURTOKENSECRET]");

$params = array(
    'status' => $message

$reply = $cb->statuses_update($params);

// display message to screen




Note: disclaimers on code/snippet usage applies – no responsibility on usage.