Twitter: micro blogging site

Twitter is one of the micro blogging site in the world. Actually people used Twitter answering a question “what are you doing?”. Twitter has done some great thing like included jaber interface to post directly from google talk or other IM who support jaber API. Twiter also provide a small API, by which you can post your msg from other site.

The API is looks like this which is collected from google code. Here is a simple view

function postToTwitter($username,$password,$message)
{

    $host = "http://twitter.com/statuses/update.xml?source=SITE_NAME&
             status=".urlencode(stripslashes(urldecode($message)));

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $host);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_POST, 1);

    $result = curl_exec($ch);
    // Look at the returned header
    $resultArray = curl_getinfo($ch);

    curl_close($ch);

    if($resultArray['http_code'] == "200"){
         $twitter_status='Your message has been sent! 
         <a href="http://twitter.com/'.$username.'">See your profile</a>';
    } else {
         $twitter_status="Error posting to Twitter. Retry";
    }
    return $twitter_status;
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }you just need a twitter account name & password and simply passed it to the function parameter and you will see the action in twitter. You can send the source name from where you send the message.

I have recently add this features to one of my application development and hereby i share this knowledge with all of you. good luck🙂

NB: To see the code working you should activate the curl library from php.ini

Reference: twitter api is used from http://code.google.com

DateJS – A Javascript Date Library

Smashing Magazine site is one of my favorite site for latest news on IT technology. Today i read the magazine and found really a interesting JavaScript library about date functionality. It do some amazing thing on the fly and the functions are very much user friendly. you can easily understand and remember those function name and their functionality. Here are some example that i found in the dateJS site.

DateJS Example

I hope all of you will have lots of fun just using this library. Please mention if you made any change to this library for better performance.

reference: http://www.datejs.com

Searching video Using YouTube API

In my recent project I have to do something like that:

  • Enter a TAG, inside a text box
  • Search in Flickr using the tag.
  • Show the search result inside my page.
  • Search in YouTube using the same tag.
  • Show the search result inside my page.
  • Play the video in my page without redirecting to the YouTube original site.

To do the following job I use Flickr API & YouTube API which helps me most. It’s become very much easy, which was too much difficult for me.

For YouTube there are lots of API available, but I found following API very much effective. You can download the API from the following link:

http://waxjelly.wordpress.com/2007/03/08/youtube-api-class-redeaux/

You just have to do the following thing:

image1

image2

It used two activeX bases Javascript class to show the video in your own page without redirecting to the orginal page.

i am feeling two much happy to have such usefull API.🙂

 

smashingmagazine.com

smashing Magazine is one of the best site that i ever find in the internet. i just heard about this. It published several articles on different aspect of programming. You can easily increase your technical knowledge from this. This site always updated with latest article, tutorial etc. It includes article and tutorial on

CSS, AJAX, PHP, Web 2.0, Ruby, XML, DHTML, JS, framework and many more.

I get much help from this site and become a big fan of this site. I hope it will also works for you.

Creating RSS Feed [Beganing]

RSS Feed is one of the best thing in modern web world. But most of the time we are not able to create our own RSS Feed. But can you imagine its simply easy when you know how to write them. Here is a beganing example to write a RSS Feed:

<?php

header( ‘Content-type: text/xml’);

?>

<rss version=”2.0″>
<channel>
<title> WordPress </title>
<description> This is a test site for WordPress </description>
<link> phpprogrammerofbangladesh.wordpress.com </link>

<?php

mysql_connect( ‘localhost’, ‘root’, ” ) or die( mysql_error() );
mysql_select_db( ‘wordpress’) or die( mysql_error() );

$sql_query = “select ID, post_date, post_title, post_content from wp_posts ORDER BY post_date DESC LIMIT 0,5”;

$result     = mysql_query( $sql_query );
while( $row = mysql_fetch_row( $result ) )
{
?>
<item>
<title>       <?=htmlentities(strip_tags($row[2]));?>             </title>
<description> <?=htmlentities( strip_tags($row[3]) );?>           </description>
<link> http://localhost/wordpress/index.php?post_id=&lt;?=$row[0];?> </link>
<pubDate>     <?=$row[1];?>                                       </pubDate>
</item>
<?php
}
?>
</channel>
</rss>

You can have more details about RSS Feed Creation from the following links

Regular Expression Example

Here i am providing some useful regular Expression which are acceptable by most of the web developers. I have found them in web.

Email Address validation

Expression: ^.+@[^\.].*\.[a-z]{2,}$

Description: Most email validation regexps are outdated and ignore the fact that domain names can contain any foreign character these days, as well as the fact that anything before @ is acceptable. The only roman alphabet restriction is in the TLD, which for a long time has been more than 2 or 3 chars (.museum, .aero, .info). The only dot restriction is that . cannot be placed directly after @. This pattern captures any valid, reallife email adress.

Date and Time

Expression: ^\d{1,2}\/\d{1,2}\/\d{4}$

Description: This regular expressions matches dates of the form XX/XX/YYYY where XX can be 1 or 2 digits long and YYYY is always 4 digits long.

You can have more information about RegX in the following site: http://regexlib.com/DisplayPatterns.aspx?cattabindex=1&categoryId=2