# Having trouble making basic REST API calls via PHP Oauth

**URL:** <https://devforum.zoom.us/t/having-trouble-making-basic-rest-api-calls-via-php-oauth/22393>\
**Category:** API and Webhooks\
**Created:** [June 25, 2020, 8:31pm UTC](https://devforum.zoom.us/t/having-trouble-making-basic-rest-api-calls-via-php-oauth/22393 "2020-06-25T20:31:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrs207](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rrs207/32/11033_2.png) [@rrs207](https://devforum.zoom.us/u/rrs207)\
**Post date:** [June 25, 2020, 8:31pm UTC](https://devforum.zoom.us/t/having-trouble-making-basic-rest-api-calls-via-php-oauth/22393/1 "2020-06-25T20:31:02Z")

</div>

**Description**  
I have successfully made a connection using the Oauth app I’ve set up via PHP, but I cannot find any examples for making a simple REST API call and seem to be having trouble even making a simple call to get a list of users.

**Error**  
My function returns the following: “code”:200,“message”:"Invalid api key or secret.

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
OAuth

**Which Endpoint/s?**  
[https://api.zoom.us/v2/users](https://api.zoom.us/v2/users)

Here is the code:  
function getAccessToken() {  
$clientID=“jLQXLFYPTyWUMyGzF3O7hA”;  
$clientSecret=“0mKFLUXLqKNYzVBxWyCmXuuPDOih94ug”;  
$content = “grant\_type=client\_credentials&client\_id=$clientID&client\_secret=$clientSecret”;  
$token\_url=“[https://zoom.us/oauth/token](https://zoom.us/oauth/token)”;  
$curl = curl\_init();  
curl\_setopt\_array($curl, array(  
CURLOPT\_URL =\> $token\_url,  
CURLOPT\_SSL\_VERIFYPEER =\> true,  
CURLOPT\_RETURNTRANSFER =\> true,  
CURLOPT\_POST =\> true,  
CURLOPT\_POSTFIELDS =\> $content  
));  
$response = curl\_exec($curl);  
curl\_close($curl);

```
	if ($response === false) {
    $retVal["Status"]=0;
		$retVal="Failed to retrieve code";
	} elseif (json_decode($response)->error) {
		$retVal["Status"]=0;
    $retVal["Message"]="Error: $response";
	} else {
    $retVal["Status"]=1;
    $retVal["Token"]=json_decode($response)->access_token;
}

	return $retVal;
}

$token = getAccessToken();
print "<pre>\n";
var_dump($token);
print "</pre>\n";

// get users
function getUsers() {
    $auth=getAccessToken();
    if (!$auth["Status"]) {
        $retVal["Status"]=9;
        $retVal["Message"]=$auth["Message"];
    } else {
        $url="https://api.zoom.us/v2/users";
        $token=$auth["Token"];
        $header = array("Authorization: Bearer $token","Content-Type: application/json");
        $curl = curl_init();
	    curl_setopt_array($curl, array(
		    CURLOPT_URL => $url,
		    CURLOPT_HTTPHEADER => $header,
		    CURLOPT_SSL_VERIFYPEER => true,
		    CURLOPT_RETURNTRANSFER => true,
		    CURLOPT_POST => true,
		    CURLOPT_POSTFIELDS => json_encode($msg)
	    ));
        $response = curl_exec($curl);

        if ($response === false) {
            $retVal["Status"]=8;
		    $retVal["Message"]=curl_error($curl);
	    } elseif (json_decode($response)->error) {
		    $retVal["Status"]=7;
            $retVal["Message"]="Error: $response";
	    } else {
            $retVal["Status"]=1;
            $retVal["Message"]=$response;
        }
        curl_close($curl);
    }
    return $retVal;
}
$users = getUsers();
print "<pre>\n";
var_dump($users);
print "</pre>\n";
```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 26, 2020, 10:47pm UTC](https://devforum.zoom.us/t/having-trouble-making-basic-rest-api-calls-via-php-oauth/22393/2 "2020-06-26T22:47:50Z")

</div>

Hey @rrs207,

Looks like you are getting a [Chatbot token](https://marketplace.zoom.us/docs/guides/chatbots/installation-and-authentication#authentication) instead of an [OAuth access token](https://marketplace.zoom.us/docs/guides/auth/oauth).

To call the [Zoom APIs](https://marketplace.zoom.us/docs/api-reference/zoom-api) other than the [Zoom Chatbot APIs](https://marketplace.zoom.us/docs/api-reference/zoom-api/chatbot-messages), you need to use the [authorization\_code grant type during OAuth](https://marketplace.zoom.us/docs/guides/auth/oauth#step-2-request-access-token).

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 10:28pm UTC](https://devforum.zoom.us/t/having-trouble-making-basic-rest-api-calls-via-php-oauth/22393/3 "2020-08-21T22:28:41Z")

</div>


