# Integrate js rest api in php website

**URL:** <https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781>\
**Category:** Web\
**Created:** [November 22, 2019, 12:15pm UTC](https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781 "2019-11-22T12:15:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![defconalert11](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@defconalert11](https://devforum.zoom.us/u/defconalert11)\
**Post date:** [November 22, 2019, 12:15pm UTC](https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781/1 "2019-11-22T12:15:47Z")

</div>

**Description/Error**  
I have php website ,i want to create zoom user in parallel when a user registers to my website ,how i could possibly achieve this task  
I included all the modules and configs needed  
thats my registration i include this between script tags at the end of the file

```php
	const axios = require('axios').default;
const config = require('./config');
const jwt = require('jsonwebtoken');

const payload = {
    iss: config.APIKey,
    exp: ((new Date()).getTime() + 5000)
};
const token = jwt.sign(payload, config.APISecret);
axios({
  method: 'post',
  url: 'https://api.zoom.us/v2/users',
  data: {
    'action': 'create',
    "user_info": {
      'email': 'testzoomphp@gmail.com',
      'type': 1,
      'first_name': 'Terry',
      'last_name': 'Jones',
    }
  },
  headers: {
    'Authorization': 'Bearer '+token,
    'User-Agent': 'Zoom-api-Jwt-Request',
    'content-type': 'application/json'
  }
})
.then(function(response) {
  //handle success
  console.log(response);
})
.catch(function(response) {
  //handle error
  console.log(response);
});

```

---

<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:** [November 22, 2019, 7:15pm UTC](https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781/2 "2019-11-22T19:15:23Z")

</div>

Hey @defconalert11,

It looks like the code you shared is JavaScript.

Are you getting errors when you try to create the user via PHP?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![defconalert11](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@defconalert11](https://devforum.zoom.us/u/defconalert11)\
**Post date:** [November 22, 2019, 11:53pm UTC](https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781/3 "2019-11-22T23:53:16Z")

</div>

@tommy sorry for lack of details I figured out a way to create a user but i have problem in creating meeting here is my code  
userMeeting.php which is a file that displays users to create meeting with

```php
          echo " <tr>
      <td>".$value1['firstname']." ".$value1['lastname']."</td>
      <td> <form action='createZoomMeeting.js' method='POST'>
                            <input type='hidden' value='".$_SESSION['email']."' name='mentoremail' id='email' >
                                <button class='btn1 btn' type='submit' name='submit'>Connect</Button>
                                </form>
                              </td>
    </tr>
 ";

```

here is my createZoomMeeting.js

```auto
	const axios = require('axios').default;
const config = require('./config');
const jwt = require('jsonwebtoken');

const payload = {
    iss: config.APIKey,
    exp: ((new Date()).getTime() + 5000)
};
const token = jwt.sign(payload, config.APISecret);
var email = document.getElementById("email").value;

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' T '+time;
axios({
  method: 'post',
  url: 'https://api.zoom.us/v2/users/'+email+'/meetings',
  data:{
  'topic': 'heyt',
  'type': '1',
  'start_time':dateTime,
  'duration': '30',
 
},
  headers: {
    'Authorization': 'Bearer '+token,
    'User-Agent': 'Zoom-api-Jwt-Request',
    'content-type': 'application/json'
  }
})
.then(function(response) {
  //handle success
alert("success");

})
.catch(function(response) {
  //handle error
alert("fail")
});

```

I want to get the email from the form which is 100% zoom user  
here is my output seems that the file don’t run it displays the code

 ![Screenshot_3](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/9/9911d9409081c1fd97aa9f2a30f900355d238d1f.png)

---

<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:** [November 25, 2019, 8:36pm UTC](https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781/4 "2019-11-25T20:36:05Z")

</div>

Hey @defconalert11,

As you said, `action='createZoomMeeting.js'` navigates to the JS file instead of running it. That is because it is trying to send a POST request to that file or endpoint.

You would need to change your `createZoomMeeting.js` to be a Node.js Express Server that accepts a POST request. Example here:

> <https://stackoverflow.com/questions/15568851/node-js-how-to-send-data-from-html-to-express/15569215#15569215>

Let me know if that helps.

Otherwise, since you are already using PHP, you could do `createZoomMeeting.php` instead, and make the API request in PHP.

> <https://stackoverflow.com/questions/48866328/post-html-form-to-php-to-rest-api>

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, 7:05pm UTC](https://devforum.zoom.us/t/integrate-js-rest-api-in-php-website/6781/5 "2020-08-21T19:05:09Z")

</div>


