skip to main |
skip to sidebar
RSS Feeds
Technical interview questions for software engineers — languages, databases, cloud, DevOps, and CS fundamentals.
Technical interview questions for software engineers — languages, databases, cloud, DevOps, and CS fundamentals.
Technical interview questions for software engineers — languages, databases, web, cloud, DevOps, and fundamentals. Browse all topics.
Posted by Raj
![]() |
| Google Spreadsheet |
<?php
/*Author: Rajesh S(rajeshstutorials.blogspot.com)
*/
ini_set('max_execution_time', 3600);
ini_set("display_errors","1");
/************************************ Login Process at google Doc
*******************************************************/
// Construct an HTTP POST request
$client_url = "https://www.google.com/accounts/ClientLogin";
$client_post = array(
"accountType" => "HOSTED_OR_GOOGLE",
"Email" => "test@gmail.com",
"Passwd" => "test",
"service" => "writely",
"source" => "Reports"
);
// Initialize the curl object
$curl = curl_init($client_url);
// Set some options (some for SHTTP)
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $client_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Execute
$response = curl_exec($curl);
// Get the Auth string and save it
preg_match("/Auth=([a-z0-9_\-]+)/i", $response, $matches);
$auth = $matches[1];
echo "The auth string is: " . $auth."
";
/********************Login Process at google Doc close*******************************************************/
$address_url="http://localhost/createxls.php";
curl_setopt($curl, CURLOPT_URL, $address_url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
$filesize=strlen($data);
$title = "test.tsv";
$headers = array(
"Authorization: GoogleLogin auth=" . $auth,
"GData-Version: 3.0",
"Content-Length: ". $filesize,
"Content-Type: text/plain",
"Slug: ". $title
);
curl_setopt($curl, CURLOPT_URL, "
https://docs.google.com/feeds/default/private/full");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
echo $response."
";
curl_close($curl);
?>
<?php
$host="localhost";
$username="root";
$password="";
$dbname="mydb";
$conn = mysql_connect($host,$username,$password,true);// Connection with
localhost
$db = mysql_select_db($dbname, $conn) or die ("Couldn't select database.");
header("Content-Type: text/plain");
$flag = false;
$result="SELECT `first_name`, `email`, `mobile` FROM `employees` ";
$query=mysql_query($result,$conn);
if(mysql_num_rows($query)>0)
{
while(($rows = mysql_fetch_assoc($query)))
{
$row = array
(
"EmpName" => $rows['first_name'], "Email" => $rows['email'], "Mobile" =>
$rows['mobile']
);
if(!$flag)
{
echo implode("\t", array_keys($row)) . "\n";
$flag = true;
}
echo implode("\t", array_values($row)) . "\n";
}
}
else
{
echo "No data found";
}
?>