API Trouble

01/31/18 Edited 12/09/19

<?php

$baseURL = "https://api.smartsheet.com/2.0";

$getSheetURL = $baseURL. "/sheets/xxxxxxxxxxxxxxxx";

$accessToken = "xxxxxxxxxxxxxxxx"; 

$headers = array("Authorization: Bearer ". $accessToken);

$curlSession = curl_init($getSheetURL);

curl_setopt($curlSession, CURLOPT_HTTPHEADER, $headers);

curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);

$getSheetResponseData = curl_exec($curlSession);

// Remove this line when done debugging

var_dump($getSheetResponseData);

$sheetObj = json_decode($getSheetResponseData);

echo "<h1>Sheet name: ". $sheetObj->name ."</h1>";

?>

 

 

Here is the code that I am attempting to run, I cannot figure out why but each time I run it it returns bool(false) and nothing for sheet name. It's like it cant reach the sheet or something. This is my first time using the smart sheet API so I am very unfamiliar with it.

 

Any help would be appreciated!

Comments

  • Have you verified that you can connect to the API, try something like this to see if you can figure out the problem? 

    $response = curl_exec($curlSession);

    $err = curl_error($curlSession);

    if ($err) {

      echo "cURL Error #:" . $err;

    } else {

      echo "$response";

    }

  • When I use that code I get this error

    cURL Error #:Unknown SSL protocol error in connection to api.smartsheet.com:443

    I'm not sure what it means and can't find a lot about it online

Sign In or Register to comment.