21
21
throw new Exception ('This application must be run on the command line. ' );
22
22
}
23
23
24
+ use Google \Client ;
25
+ use Google \Service \Script ;
26
+
24
27
/**
25
28
* Returns an authorized API client.
26
- * @return Google_Client the authorized client object
29
+ * @return Client the authorized client object
27
30
*/
28
31
function getClient ()
29
32
{
30
- $ client = new Google_Client ();
33
+ $ client = new Client ();
31
34
$ client ->setApplicationName ('Google Apps Script API PHP Quickstart ' );
32
35
$ client ->setScopes ("https://www.googleapis.com/auth/script.projects " );
33
36
$ client ->setAuthConfig ('credentials.json ' );
@@ -82,12 +85,12 @@ function getClient()
82
85
* project, and log the script's URL to the user.
83
86
*/
84
87
$ client = getClient ();
85
- $ service = new Google_Service_Script ($ client );
88
+ $ service = new Script ($ client );
86
89
87
90
// Create a management request object.
88
91
try {
89
92
90
- $ request = new Google_Service_Script_CreateProjectRequest ();
93
+ $ request = new Script \ CreateProjectRequest ();
91
94
$ request ->setTitle ('My Script ' );
92
95
$ response = $ service ->projects ->create ($ request );
93
96
@@ -98,7 +101,7 @@ function helloWorld() {
98
101
console.log('Hello, world!');
99
102
}
100
103
EOT ;
101
- $ file1 = new Google_Service_Script_ScriptFile ();
104
+ $ file1 = new Script \ ScriptFile ();
102
105
$ file1 ->setName ('hello ' );
103
106
$ file1 ->setType ('SERVER_JS ' );
104
107
$ file1 ->setSource ($ code );
@@ -109,12 +112,12 @@ function helloWorld() {
109
112
"exceptionLogging": "CLOUD"
110
113
}
111
114
EOT ;
112
- $ file2 = new Google_Service_Script_ScriptFile ();
115
+ $ file2 = new Script \ ScriptFile ();
113
116
$ file2 ->setName ('appsscript ' );
114
117
$ file2 ->setType ('JSON ' );
115
118
$ file2 ->setSource ($ manifest );
116
119
117
- $ request = new Google_Service_Script_Content ();
120
+ $ request = new Script \ Content ();
118
121
$ request ->setScriptId ($ scriptId );
119
122
$ request ->setFiles ([$ file1 , $ file2 ]);
120
123
0 commit comments