Monday, 7 April 2014

Export in Excel doc in php


//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

       //header("Content-Length: " . strlen($out));

       header("Content-type: application/vnd.ms-excel");

       //header("Content-type: application/octet-stream, charset=UTF-8; encoding=UTF-8");

       header("Content-Disposition: attachment; filename=Deal_calender.xls");

       $out = html_entity_decode( $out ,ENT_NOQUOTES,'utf-8');

       $out = chr(255).chr(254).iconv("UTF-8","UTF-16LE",$out);

       echo $out;  

       exit;

Facebook Auto Post functionality


<?php
$url="http://google.com";
$title="Test Content";
$message = "$title $url";
$fb_access_token = "----";  // FB access token
$fb_user_id ="---";   //Facebook user id
$post_arg = array("access_token" => $fb_access_token, "message" => $message, "id" => $fb_user_id, "method" => "post");
fb_curl_function("https://graph.facebook.com/feed", "POST", $post_arg);

function fb_curl_function($req_url = "", $type = "", $arguments =  array()){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $req_url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if($type == "POST"){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arguments);
}
$result = curl_exec($ch);
curl_close ($ch);
return $result;
}

?>

To get random image


<?php for($i=0;$i<10;$i++){?>

<img src="http://www.gravatar.com/avatar/<?php echo md5(rand(1,100)) ?>?d=wavatar"  alt="img" />

<?php } ?>

Feet/Inches to Meters Converter & Lbs to Kgs Converter

 <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8" />   <title>Feet/Inches ⇄...