It's All About Me

make them benefit

Shortest piece of php code to update twitter status

with one comment

There are huge resources of php to update twitter status using API. But a few days back i found a very small piece of php code to update twitter status which uses stream. Here are the code –

  $context = stream_context_create(array(
    'http' => array(
	  'method'  => 'POST',
      'header'  => sprintf("Authorization: Basic %s\r\n", base64_encode("$username:$password")).
                   "Content-type: application/x-www-form-urlencoded\r\n",
      'content' => http_build_query(array('status' => $message)),
	  'timeout' => 5,
    ),
  ));

  $ret = file_get_contents('http://twitter.com/statuses/update.xml', false, $context);

Put username, password, message as needed. I think this is the php shortest code ever to update twitter status. Enjoy!

Written by kodegeek

January 22, 2010 at 2:44 am

Posted in Php

Users Export/Import – EE to WordPress

with 2 comments

A few days ago i’ve imported about 40000+ subscribers from expressionengine to wordpress. It’s a very easy job but for huge data – it came to a issue to me. Here are the step by step stuffs that i followed. This may help you ;)
Read the rest of this entry »

Written by kodegeek

January 21, 2010 at 12:50 pm

My Wishlist for 2010

with 10 comments

1. Want to be father :oops:
2. Zend PHP5 Certification
3. Get a Macbook Pro 15 inch
4. Get a Nikon D90

Written by kodegeek

January 5, 2010 at 1:48 pm

Posted in Misc

php 5 oop gotchas you must know

with 3 comments

I was reading php 5 oop stuffs from http://php.net site, few things i noted for myself, these you should learn too if aren’t yet, so go on. These notes taken from php.net –

Inheritance – It is not possible to extend multiple classes; a class can only inherit from one base class.

Static – To access a static property, we can use self var inside class like echo self::$foo;
Read the rest of this entry »

Written by kodegeek

January 5, 2010 at 2:04 am

Posted in Php

Cakephp, Auth and Empty Password Problem

with 3 comments

Auth component is excellent one that i love in Cakephp for authentication but one problem i faced with this, empty password problem. That is – to add a new user, it takes empty password if we use password field. Model validation doesn’t work for password field if we put no value in password field, because – auth component create a hashed password after the form submission with empty value, so it can pass Model validation easily. I solved it another way – here is it.
Read the rest of this entry »

Written by kodegeek

December 17, 2009 at 1:26 pm

Posted in CakePhp

Tagged with