TannieSpace

geekery, drawing and then some

Posts about twitter

More geekery with twitter and flickr stuff

A couple of weeks ago I found and edited a php script to help me post photos to flickr from Tweetie for iPhone (now Twitter for iPhone -- do keep up...). After using it for a while I realised the title of the photos got a bit too long for my taste and I spend a little time tweaking. I've now changed it so that the first sentence (up to the first . or ! or ?) becomes the title. The rest becomes the description of the photo. For me this works out pretty well.

I added the following lines (changing the last line of my previous tweak to prevent confusion):

$string = preg_replace("/#\w+/i", '', $title); //previously the above line said: $title pregreplace("/#\w+/ i", '', $title);
if (preg_match("/^.*(\.|\!|\?)/U", $string, $matches)) {
    $title = $matches[0];
    $description = preg_replace("/^.*(\.|\!|\?)/U", '', $string);
}
else {
     $title = $string;
     $description = "";
}

right before:

$parameters = array( 'api_key' => API_KEY, 'auth_token' => API_TOKEN, 'tags' => $tags, 'title' => $title, 'description' => $description, );

Note that I also added that last field in there ('description'). I haven't completely tested it; however, my limited tests seemed to work fine. I don't really know much about php, so I probably used more lines than I needed. This way I could keep track of what I did though, and I think I'll still understand my changes a couple of months from now.


Geeking out with twitter and flickr stuff

Recently I found a php script by Chris Morrel which allows you to post photos to flickr (and get the correct flic.kr short url back) from Tweetie 2. I tweaked it a little to get used hashtags as flickr-tags and to have them removed from the title (the script uses the message as the title).

Right after:

$tags = FLICKR_TAGS;
if (TAG_WITH_HANDLE) {
$tags .= ' @' . $_POST['username'];
}

I added:

preg_match_all('/#(\w+)/', $title, $matches);
foreach ($matches[1] as &$tag) {
    $tags .= ' ' . $tag;
    }
$title = preg_replace("/#\w+/i", '', $title);

It worked as I wanted, so yay!