shell - Transform PHP script into executable -


i trying create script upload file google drive. when run it, works perfectly. here's working code:

public function uploadtodrive() {     $client = new google_client();     $client->setclientid(mage::getstoreconfig('mtm_google/drive/client_id'));     $client->setclientsecret(mage::getstoreconfig('mtm_google/drive/client_secret'));     $client->setredirecturi(mage::getstoreconfig('mtm_google/drive/redirect_uri'));     $client->setscopes(array('https://www.googleapis.com/auth/drive.file'));      session_start();      if (isset($_get['code']) || (isset($_session['access_token']) && $_session['access_token'])) {         if (isset($_get['code'])) {             $client->authenticate($_get['code']);             $_session['access_token'] = $client->getaccesstoken();         } else {             $client->setaccesstoken($_session['access_token']);         }          $service = new google_service_drive($client);          $file = new google_service_drive_drivefile();         $file->setname('analysis.csv');         $file->setdescription('a test document');         $data = file_get_contents('temp.csv');          $service->files->create($file, array(             'data' => $data,             'mimetype' => 'text/csv',             'uploadtype' => 'multipart'         ));         echo 'success!';         unlink('temp.csv');     } else {         $authurl = $client->createauthurl();         header('location: ' . $authurl);         exit();     } } 

this script should executable console, , not executed url. when try execute console, nothing happens because session variables , redirects can't handle. how can modify script in order executable console?

simply define/set variables : $_get, $_session, ....
variables can passed arguments console using $argv[]


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -