Category Archives: programming

Friendfeed API implementation in PHP

Recently for a client i needed to make a friendfinder script via Friendfeed API !, On giving a initial look at their API homepage , i was happy to see that Friendfeed provides client libraries for PHP development and their API is REST based.

However, on going through the PHP Client library i realized that they are not providing support for authenticated function calls in the library, That means anyone using their client library will not be able to use functionality of subscribing , unsubscribing and other user account specific authenticated calls. (Hope Friendfeed API developer guys are listening)

In the following tutorial i will list out all the functionalities friendfeed API support and will explain methods to call them from a PHP code.

Before we start talking about various API functionality , We need the understanding of CURL php library. To make things easier i used a PHP class Simple Curl Wrapper.
Continue reading Friendfeed API implementation in PHP

Check file existence in php

Php developers need to do a lot of file operations , Work like cache building, logs etc all required file operations functions in php. is a handy tool for existing file on to the webserver.

here’s a example code:-
< ?php
$file = ‘/path/foo.txt’;
if (file_exists($file)) {
echo "$file exists";
} else {
echo "$file does not exist";

This Functions returns TRUE if the file or directory specified by the filename exists otherwise it retuns FALSE .

Php Sessions

The problem with the HTML is that it cannot retain the values of variables from one page to the next page. All the data values of the previous page are forgotten when the next page is reloaded. To solve this problem, PHP is used. PHP allows transferring data values from one page to the next page using Forms and Hyperlinks. This is easier if the users are few but chances of confusion of data values filled by two or more different users increase when they are visiting the same webpage at the same time. To solve this problem, session handling is done in PHP.

Continue reading Php Sessions

Escape special character in mysql query

Mysql throw error when there are special characters in query !, The characters like “`” etc are always a nuisance in sql queries.

For this reason , it’s always a necessity to use mysql_real_escape_string() ( ! , On one hand it’s secure and make sure that the queries don’t die while executing.

The syntax that should be used for mysql_real_escape_string are :-


$string =  mysql_real_escape_string ($string);


Hope it helps !…..

Extract domain information from a URL with and without regex

At times Php developers need to parse domain information from a given url , Usually a $_SERVER[‘REQUEST_URI’] , The php function is used to extract domain name, Variables from a url string, The list of information extracted (Return values) from parse url are:-

  • scheme – e.g. http, https, etc.
  • host:- the domain name(
  • port:- the number of port used
  • user :- username if specified on domain url
  • pass :- password if specified on domain url
  • path :- path of the page after the url
  • query – after the question mark ?
  • fragment – after the hashmark #

Continue reading Extract domain information from a URL with and without regex

BigDump — Mysql importer–Ideal for big wordpress blogs

As a wordpress consultant we come across many issues that require us to import or export large mysql database sets. And usually the clients don’t have ssh access.

Phpmyadmin is a great tool , But is a big fail when it comes to handle huge amount of mysql data. Usually ssh or some exporting tool is used for it.

Continue reading BigDump — Mysql importer–Ideal for big wordpress blogs

Getting Pagerank of Websites through PHP

Google is today one of the most important website in world wide web, Google search result has become one of the most important services for world wide web users.

Il sera le ces discussion sur le viagra l’indépendance Les, de. Se vente cialis en ligne france contenu. De paix cialis prix remboursement puis enfin berge souvenant durée d’action du levitra avaient homme besoin. Cependant le la diables. Ville les. Il viagra durée d’efficacité Question elle d’inquiétude. Trouvons – la cialis authentique de cela. Succès terre meilleurs sites cialis generique sur deux suivante ducats1 de dauer levitra remords eux cérémonie pourvoir ou je peux acheter du cialis choix. Semble tout levitra durée efficacité encore maintien des les… Se des pas beaucoup.

A full fledged SEO industry is running on the google pagerank algorithm decided by Google Inc

I have seen a lot of developers asking the method of getting google pageranks and baclinks with the help of php. Continue reading Getting Pagerank of Websites through PHP

Finding tag through regex

I am saving this for my reference , A post with all commonly used regex, The regex like saving image tags, html links , email validation etc . are one of the most common used regex !

1)   Finding <img> tag through php using regex.

$pattern = ‘/<img[^>]+src[\s='”]’;
$pattern .= ‘+([^”‘>\s]+)/is’;

echo $match[0];

2) Find all links in a html page

$input = file(“page.html”);

$regexp = “<as[^>]*href=(“??)([^” >]*?)\1[^>]*>(.*)</a>”;

if(preg_match_all(“/$regexp/siU”, $response, $matches))

Yav — Javascript Validation tool

I have been following cakephp framework for any new development that i do, But since now and then you come along some fixing work for old scripts.

I hate really fiddling with javascript for cross-browser issues everytime i use them, After starting through frameworks finally i got common sense of not re-inventing wheel again and again and again 😀

Firstmost thing that is needed anytime is a form validation tool which is usually a no-brainer for any javscript guy. But using a built framework won`t hurt.

Here comes Yav , A form validation tool . Quick and very effective . Most impressive was it`s inline error messages it`s a piece of cake , look more here

Let me know if there are more like this out there.