{"id":253,"date":"2007-03-28T20:58:41","date_gmt":"2007-03-28T20:58:41","guid":{"rendered":"http:\/\/beta.robertprice.co.uk\/robblog\/2007\/03\/using_twitter_from_perl-shtml\/"},"modified":"2007-03-28T20:58:41","modified_gmt":"2007-03-28T20:58:41","slug":"using_twitter_from_perl-shtml","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/","title":{"rendered":"Using Twitter From Perl"},"content":{"rendered":"<p>\nThe world and his dog is currently looking at <a href=\"http:\/\/www.twitter.com\/\">Twitter<\/a> and eyeing up the possibilities it offers.\n<\/p>\n<p>\nI thought i&#8217;d jump on the bandwagon, and have a look at the <a href=\"http:\/\/twitter.com\/help\/api\">Twitter API<\/a>.\n<\/p>\n<p>\nI wanted to post to a timeline, so the solution is to use one of the update methods. I chose to the XML one, though there is a JSON one also available.\n<\/p>\n<p>\nTo post to the timeline, Twitter expects an HTTP POST request with a status parameter containing the message you want to post. It associates this to your account by using HTTP&#8217;s basic authorization functionality.\n<\/p>\n<p>\nIt&#8217;s simple to throw together a spot of <a href=\"http:\/\/www.perl.com\/\">Perl<\/a> code to post messages to Twitter knowing this. Have a look at this example&#8230;\n<\/p>\n<div class=\"code\"><code><br \/>\nmy $message = \"A test post from Perl\";<br \/>\nmy $req = HTTP::Request-&gt;new(POST =&gt;'http:\/\/twitter.com\/statuses\/update.xml');<br \/>\n$req->content_type('application\/x-www-form-urlencoded');<br \/>\n$req->content('status=' . $message);<br \/>\n$req->authorization_basic($username, $password);<br \/>\nmy $resp = $ua-&gt;request($req);<br \/>\nmy $content = $resp-&gt;content;<br \/>\nprint $content;<br \/>\n<\/code><\/div>\n<p>\nYou need to set <var>$username<\/var> and <var>$password<\/var> to your username and password, and $message to whatever message you want to appear on your timeline (in this case, &#8220;A test post from Perl&#8221;).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The world and his dog is currently looking at Twitter and eyeing up the possibilities it offers. I thought i&#8217;d jump on the bandwagon, and have a look at the Twitter API. I wanted to post to a timeline, so the solution is to use one of the update methods. I chose to the XML &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using Twitter From Perl&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[17,25,47,75,80],"class_list":["post-253","post","type-post","status-publish","format-standard","hentry","category-dev","tag-dev","tag-http","tag-perl","tag-web-development","tag-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using Twitter From Perl - Robert Price<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Twitter From Perl - Robert Price\" \/>\n<meta property=\"og:description\" content=\"The world and his dog is currently looking at Twitter and eyeing up the possibilities it offers. I thought i&#8217;d jump on the bandwagon, and have a look at the Twitter API. I wanted to post to a timeline, so the solution is to use one of the update methods. I chose to the XML &hellip; Continue reading &quot;Using Twitter From Perl&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2007-03-28T20:58:41+00:00\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"Using Twitter From Perl\",\"datePublished\":\"2007-03-28T20:58:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/\"},\"wordCount\":160,\"keywords\":[\"Dev\",\"HTTP\",\"Perl\",\"Web Development\",\"XML\"],\"articleSection\":[\"Dev\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/\",\"name\":\"Using Twitter From Perl - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"datePublished\":\"2007-03-28T20:58:41+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using_twitter_from_perl-shtml\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Twitter From Perl\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Twitter From Perl - Robert Price","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/","og_locale":"en_GB","og_type":"article","og_title":"Using Twitter From Perl - Robert Price","og_description":"The world and his dog is currently looking at Twitter and eyeing up the possibilities it offers. I thought i&#8217;d jump on the bandwagon, and have a look at the Twitter API. I wanted to post to a timeline, so the solution is to use one of the update methods. I chose to the XML &hellip; Continue reading \"Using Twitter From Perl\"","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/","og_site_name":"Robert Price","article_published_time":"2007-03-28T20:58:41+00:00","author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"Using Twitter From Perl","datePublished":"2007-03-28T20:58:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/"},"wordCount":160,"keywords":["Dev","HTTP","Perl","Web Development","XML"],"articleSection":["Dev"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/","name":"Using Twitter From Perl - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"datePublished":"2007-03-28T20:58:41+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using_twitter_from_perl-shtml\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"Using Twitter From Perl"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=253"}],"version-history":[{"count":0,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/253\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}