1

I am working on google spreadsheet and want to update data that I want. I read this article and update the data successful on its console. Now I want to update data with PHP curl and I am a little bit confuse for these options

  1. valueInputOption=USER_ENTERED
  2. "majorDimension": "COLUMNS"

When I entered my desired values in above Article console editor its update data successfully and give me following results

Request

PUT https://sheets.googleapis.com/v4/spreadsheets/**************F9NM/values/A4:G4?valueInputOption=USER_ENTERED&key={YOUR_API_KEY}

{
 "majorDimension": "COLUMNS",
 "values": [
  [
   "myemail@mail.com"
  ],
  [
   "First Name"
  ],
  [
   "Last Name"
  ],
  [
   "Mobile"
  ],
  [
   "URL"
  ],
  [
   "US"
  ],
  [
   "54654654654"
  ]
 ]
}

Response

Cache-Control:  private
Content-Encoding:  gzip
Content-Length:  143
Content-Type:  application/json; charset=UTF-8
Date:  Sat, 08 Oct 2016 09:34:11 GMT
Server:  ESF
Vary:  Origin, X-Origin, Referer

{
 "spreadsheetId": "******************F9NM",
 "updatedRange": "Sheet1!A4:G4",
 "updatedRows": 1,
 "updatedColumns": 7,
 "updatedCells": 7
}

So my confusion is that how can i put my values (that I want to update) in this USER_ENTERED and how can I set majorDimension": "COLUMNS in php curl api link.

I searched a lot and read many articles about Update google api spreadsheet but I get nothing helpful or use full

Here is my code that I want to try in php file:

$curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,"https://sheets.googleapis.com/v4/spreadsheets/*********F9NM/values/A4:G4?valueInputOption=USER_ENTERED&key=******************38");
    //curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');

    $result = curl_exec ($curl);
    curl_close ($curl);
Rubén
  • 34,714
  • 9
  • 70
  • 166
deemi-D-nadeem
  • 2,343
  • 3
  • 30
  • 71

1 Answers1

0

Reading from this cURL guide from 11. Custom Request Elements, You can use POST/PUT method by using cURL -D then add the values.

"It should be noted that curl selects which methods to use on its own depending on what action to ask for. -d will do POST.."

There's also a sample provided in this SO thread that might be of help:

curl -X PUT -d arg=val -d arg2=val2 localhost:8080

Community
  • 1
  • 1
adjuremods
  • 2,938
  • 2
  • 12
  • 17