Archive for March 3rd, 2008
Build simple contact application in android
Google’s open handset alliance is soon gonna hit market. So its definitely worth enough trying to develop expertise in android platform. Here is a simple tutorial that describe how to start by illustrating a simple contact application by one of google developer.
Trackback how to implement ?
Trackback is a technology used by content publishing software like wordpress, movabletype, blogger etc to acknowledge url added in the commenting of post. The trackback acknowledge is sent using network ping from the originating site to receiving site. Let me demostrate how it works with a diagram shown below.

Trackback can also be used as a link building mechanism. Let me explain how it can be implemented using php. One php library is also there to do this. But now i am going to explain a simple mechanism in php. As i already explained it is done via ping method. The ping method is normal HTTP POST. The ping is sent to the trackback uri of the receiving post. The parameter required is url. The server will send a XML response for the comment. The XML response may be either a success result or a failure result with XML format response.
Success :
< ?xml version=”1.0″ encoding=”utf-8″?>
< response>
< error>0< /error>
< /response>
Failure:
< ?xml version=”1.0″ encoding=”utf-8″?>
< response>
< error>1< /error>
< message>Error message< /message>
< /response>
PHP implementation.
$params['http']['method'] = 'POST'; $params['http']['header'] = 'Content-Type: application/x-www-form-urlencoded'; $params['http']['content'] = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
Send the ping command with the parameters above and capture the result.
The parameters should be URL encoded since we are using simple POST mechanism.
// Create the context from the formatted array $context = stream_context_create($params);// Open a stream to the url, save it in the pointer $fp $fp = @fopen($trackback_uri, 'rb', false, $context); // Send the header and get the results, saved in $response $response = @stream_get_contents($fp); // Always close for good measure fclose($fp);
What next is to parse the message whether its success or not ?
// If this is true, there was no error if (stripos($response, '<error>0</error>')) $outcome = "All clear! Trackback was sent successfully."; else { // Find the beginning and end of the message element $start_resp = stripos($response, '<message>'); $end_resp = stripos($response, '</message>'); // substr will return the actual message element, // with the tags included $outcome = substr($response, $start_resp, $end_resp - $start_resp - 1); // Replace the tags with blank space $outcome = str_replace('<message>', '', $outcome); $outcome = str_replace('</message>', '', $outcome); $outcome = "Error: " . $outcome;
}// Echo the results. I formatted 'error' to be red. echo "<p class='error>$outcome</p>";
Thanks to earn web cash for the php code
