Custom "source" fields in Laconica posts using Curl

Some of my friends on the Twit Army have been asking how I was able to override the source string when posting microblogs. Here's an example of what I mean.

This is a normal post from the web


Notice that it says "from web".

This is a post from curl with the custom source


In this case it's "from a land down under ♫"

This is easily done with the command line tool "Curl" and the Laconica API

Posting from Windows

  1. Download Curl for Windows here .
  2. Extract to a folder of your choice. I'll use C:\curl for simplicity.
  3. Click Start -> Run and enter "cmd" in the run window to open a command prompt.
  4. From the command prompt type cd C:\curl. You should now be in the C:\curl> directory.
  5. Type:

curl.exe "http://army.twit.tv/api/statuses/update.xml" -u {username}:{password} -d "status={your message to post}&source={your custom source}"

replacing the fields in curly braces { } with your own data.

For example:

curl.exe "http://army.twit.tv/api/statuses/update.xml" -u kylehase:supersecret -d "status=Watching FamilyGuy. Peter just lost a finger.&source=my couch"





That's it. I'll update this post later to explain how to add the curl command to %PATH% on Windows and use a scripts to make posting even easier.

Posting from Linux or OSX

Unix based operating systems usually come with Curl. If not, you should be able to get it via yum or apt-get curl from your distro repository. After that, simply run the same command from above without the .exe extension.

curl "http://army.twit.tv/api/statuses/update.xml" -u kylehase:supersecret -d "status=Eating muffins&source=Kitchen table"





Update 1 - Batch script

Here's a quick and dirty batch script I wrote up for Windows. Save it as a .bat file in the same directory as curl.exe and change the username and password to your own. Password is obviously not encrypted so be careful.

@ECHO off
rem Place this script in the same directory as curl.exe.  

rem Change the username and pass to your username and pass
SET user=yourname
SET pass=yourpass
rem Change this line only if you're using a different instance of Laconica
SET api="http://army.twit.tv/api/statuses/update.xml"

rem == Shouldn't need to change anything below here ==
SET /P status="Status (140): "
SET /P source="Source (32): "
curl.exe %api% -u %user%:%pass% -d "status=%status%&source=%source%"
SET user=
SET pass=
SET api=
SET status=
SET source=
pause

All code on this site is free for use at your own risk and provided as-is under the WTFPL license unless otherwise stated. Attribution is appreciated but not required.
Blog content, with the exception of externally quoted material, is licensed under the Creative Commons Attribution 3.0 license