Pages

Monday, August 5, 2013

PHP CODE FOR CREATING A NEW FOLDER IN GOOGLE DRIVE API

         PHP CODE FOR CREATING A NEW FOLDER IN GOOGLE DRIVE API




require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
require_once 'google-api-php-client/src/contrib/Google_Oauth2Service.php';
$client = new Google_Client();
// Get your credentials from the APIs Console
//$client->setApplicationName('Google+ PHP Starter Application');
$client->setClientId('your client id');
$client->setClientSecret('your client secret id');
$client->setRedirectUri('your redirect uri');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));


$client->setAccessToken(file_get_contents('conf.json'));
if ($client->getAccessToken()) {
//It means that I have the right to manipulate whatever service
// Choose the service you want to use
    $service = new Google_DriveService($client);

    $file = new Google_DriveFile();
    $file->setTitle('test'); //name of the folder
    $file->setDescription('A test folder');
    $file->setMimeType('application/vnd.google-apps.folder');
    $createdFile = $service->files->insert($file, array(
        'mimeType' => 'application/vnd.google-apps.folder',
    ));

   // print_r($createdFile);
    print "folder created sucessfully";
   
    echo "folder id is" . $createdFile->id;
   
}

CODE TO UPLOAD ANY TYPE OF FILE TO GOOGLE DRIVE API AFTER CREATING AN ACCESS TOKEN USING PHP

CODE TO UPLOAD ANY TYPE OF FILE TO GOOGLE DRIVE API   AFTER CREATING AN ACCESS TOKEN USING PHP

require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
require_once 'google-api-php-client/src/contrib/Google_Oauth2Service.php';


$client = new Google_Client();

// Get your credentials from the APIs Console
//$client->setApplicationName('Google+ PHP Starter Application');
$client->setClientId('your client id');
$client->setClientSecret('your client secret id'); 
$client->setRedirectUri('your resirect uri');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));


$client->setAccessToken(file_get_contents('conf.json'));
if ($client->getAccessToken()) {
//It means that I have the right to manipulate whatever service
// Choose the service you want to use
    $service = new Google_DriveService($client);

    $file = new Google_DriveFile();
    $file->setTitle('hai');
    $file->setDescription('A test document');
    $file->setMimeType('text/plain');
    $data = file_get_contents('hello.txt'); //example file
    
    $createdFile = $service->files->insert($file, array(
        'data' => $data,
        'mimeType' => 'text/plain',
    ));
   
   // print_r($createdFile);
    print "file uploaded sucessfully";
   
    

?>

Sunday, August 4, 2013

CODE TO CREATE A CONNECTION WITH GOOGLE DRIVE API USING PHP AND SAVE AUTHENTICATION TOKEN


CODE TO CREATE A CONNECTION WITH GOOGLE DRIVE API USING PHP AND SAVE AUTHENTICATION TOKEN 

require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';

session_start();
$client = new Google_Client();
// Get your credentials from the APIs Console
//$client->setApplicationName('Google+ PHP Starter Application');
$client->setClientId('your client side');
$client->setClientSecret('your client secret id');
$client->setRedirectUri('your client redirect uri');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));

////I will address building permit
$authUrl = $client->createAuthUrl();
print "Connect Me!";
echo $authUrl;
//Return of the address with the code that I can autenticarme
if (isset($_GET['code'])) {
  $accessToken = $client->authenticate($_GET['code']);
  
  file_put_contents('conf.json', $accessToken);
  $client->setAccessToken($accessToken);
  $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}


Tuesday, June 30, 2009

Strengthening Tech Trends

The next Green Revolution seems to be happening in the field of electronics and IT, with a slew of products ranging from servers, storage solutions and laptop computers to even point -of-sale counters claiming eco- friendliness as their unique selling proposition.

But what really does the ‘greenness’ of a product refer to? Is it merely the quality of being energy efficient and working on a smaller footprint? While energy efficiency is a key aspect of a product’s greenness, a product must adhere to many more factors in order to truly qualify as green

For example, eliminating harmful substances like vinyl plastics such as PVC and Brominated flame retardants (BFRs) from products and avoiding the use of other toxic chemicals in the manufacturing process, is an important requirement for eco – friendliness. The amount of floor – space occupied by the product, length of its useful life, ability to discard, reuse or recycle it in an environmental – friendly way at end of its life, etc are other key aspects.

Companies are likely to strengthen their greening exercises with eco- friendliness becoming more of a necessity than a value-add today, thanks to great awareness amongst consumers and a deeper interest shown by activists.

The year 2007and 2008 saw the rise of ‘green’ as a buzzword amongst the electronics and IT industry in India, and the word was thrown about in marketing materials and news reports. Yet, studies by Greenpeace International showed that very few companies in India qualified as being eco-friendly, and even giants like HCL have much ground to cover. Internationally, companies like SONY, SAMSUNG and DELL have consistently performed well in Green peace’s ‘green’ electronics reading.