Top.Mail.Ru
? ?

Apr. 17th, 2009

watch

posted via php/flat API

hello world

success

I was now able to use the LJ "flat" API to create this post (subject and body)

so now, i can continue making my own PHP twitter to lj interface!

$timestamp is hour, mon, day, hour, min as per spec

$ch = curl_init("http://www.livejournal.com/interface/flat");
$H[0] = "Content-Type";
$H[1] = "application/x-www-form-urlencoded";
$MSG ="mode=postevent&user=USERNAME&password=PASSWORD&subject=posted+via+php/flat+API&event=hello+world";

curl_setopt($ch, CURLOPT_POSTFIELDS, "$MSG$timestamp");
curl_setopt($ch, CURLOPT_HTTPHEADER, $H);
curl_setopt($ch, CURLOPT_POST, true);
curl_exec($ch);
curl_close($ch);


n.b. this method is not checking for LJ return status, as the API is robust enough to do a lot more than just post a blog entry.
Tags: ,

Apr. 12th, 2009

harmonica

I am a fucking genius!


Woohoo. Not only did I finally bite the bullet and write code to automajically generate my work site's google sitemap (400+ urls!) in real time.. thanks codeninjaking for being the ear i had to bend to get there!

I learned how to make my own php hack of twitter API which is really very ferkin easy, as it just uses curl — so you can even do via command line!

My Code (you're welcome
neoliminal!)
$ch = curl_init("http://twitter.com/statuses/update.xml");
curl_setopt($ch, CURLOPT_USERPWD, 'USERNAME:PASSWORD');

/* now post your status:
Be sure to URL encode as necessary.
Should not be more than 140 characters.
*/
curl_setopt($ch, CURLOPT_POSTFIELDS, 'status="Your Message Here"');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_exec($ch);
curl_close($ch);

And that werk'd for me!

You'll get a spew back from the server but anything other than an error means SCHWING!
Tags: , , , ,
guitar

February 2017

S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728    

Tags

Syndicate

RSS Atom
Powered by LiveJournal.com