Skip to main content

Here’s a basic snippet of PHP that lets me execute queries against the v2 API and return the data as JSON. I hope it can provide a leg up and save someone time as they get started.


Just enter your own API key, change the URL to match yours, and put in your query.


$token = ' Personal API Token]';
$tempUrl = "https://api.monday.com/v2/";

$query = ' {
users{
id
email
name
}
}';
$headers = ='Content-Type: application/json', 'User-Agent: :MYTEAM] GraphQL Client', 'Authorization: ' . $token];
$data = @file_get_contents($tempUrl, false, stream_context_create(e
'http' => ;
'method' => 'POST',
'header' => $headers,
'content' => json_encode(e'query' => $query]),
]
]));
$tempContents = json_decode($data, true);

Thank you for the suggestion.

I removed that header and changed the authentication type to “API Key”.


But I still make it to the “ELSE” portion below:


if(res.indexOf(‘Account.Name’) > 0){

auth.authenticationSuccess();

} else {

auth.authenticationFailed(‘user/password incorrect’);

}


I am attempting to contact DOMO too, but their third party connector person must be out for the holidays.


Thanks!


Do let us know what Domo says! Happy to help further once you hear from them.


It turns out that the connection was successful - but my code for checking the return value was incorrect.

Since this is an API connection there is no username/password sent.


So when I check this:


if(res.indexOf(‘Account.Name’) > 0)


it will always return zero.


Instead, I need to check this:


httprequest.getStatusCode() == 200)


Now I just need to figure out how to write my query.


This works in the Monday developer site:


query {

boards () {

name

state

board_folder_id

owner {

id

name

}

}

}


But the DOMO Connector Builder does not like the format.


Thanks!


I made some progress but I have another question.

When I want to loop thru all of the Boards, I have a ‘for next’ loop with the upper limit of ‘Boards.Length’


I also need to grab all of the Items and Groups - but they don’t have that ‘Length’ property (or a count)


Do you have any documentation I can look at to figure that out?


I was looking here: https://monday.com/developers/v2#queries-section


But that does not even show the Boards.Length (even though I am currently using it!)


Thanks!


I’m a little new to API and Monday.com as well. I am building an Administrative Dashboard for my employees and we use Monday.com heavily for our Project & Estimation Planning and Tracking. I would like to create a table view of the Projects I have listed in a board on Monday.com to a back-end dashboard.


I currently use the following coding languages and infrastructures:

PHP 7.3

Codeigniter 3.10

CI Bonfire 1.8


At this time, I am simply trying to figure out how to display all information for each item in a row (using PHP) to create a table view for my technicians in their Admin Dashboard of my website.


Can someone assist me with the proper query? I’ve tested multiple ways in the Try It Yourself Section to no avail.


@tburks2392


I use the following which will produce an array for you to do whatever you see fit:


<?php
$token = 'YOURTOKEN';
$tempUrl = "https://api.monday.com/v2/";

$query = 'query {
boards (ids: NUMERICBOARDID) {
groups (ids: group_title) {
items {
id
name
column_values {
id
text
title
}
}
}
}
}';
$headers = ['Content-Type: application/json', 'User-Agent: [myteam] GraphQL Client', 'Authorization: ' . $token];
$data = @file_get_contents($tempUrl, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $query]),
]
]));
$tempContents = json_decode($data, true);

If you just want the whole board and don’t care about a specific group use the following query:


query {
boards (ids: 007007007) {
items {
id
name
column_values {
id
text
title
}
}
}
}

Hey y’all, we just released a PHP API quickstart! It will go through making API calls as well as a little bit about our GraphQL schema 🙂


Here it is: PHP Quickstart


Hi, I am very new to the API implementation and sorry for my poor english.

I copy the code of PHP Quickstart - Making your first API call and replace with my own API v2 Token , however it returns “null” value.

I not sure which part is wrong ,please help me. 😣


Hi @sim,


Have you copied the first example from the link?


Which environment are you using to make the API call?


Are you able to share some screenshots with us?


Hi @mitchell.hudson, basically I just copied the example and replace it with API v2 Token copied from Admin panel.


I test run the code on localhost and this it the output :

image


In addition, i copied the API v2 token and tried it on Developers tools, it shows “Internal server error” .



Remove the @ before file_get_contents function.

That prevents any error from showing.

You should be able to see what’s wrong.


Hi @sim,


It looks like your query is incorrect.


It looks like you are missing the ‘boards’ keyword in the query before you provide the variables to the function.


If you restructure your query to be the below:

$query = '{ boards(ids: d1,2,3,], limit:100) { name id items { name column_values{id type text } } } }';

You should have a valid query.


You can test this in GraphiQL.


One other note that I will make, you probably is that if you are submitting the ids variable, you probably don’t need the limit variable as well given this will restrict the number of responses anyway


Hi @rob and @mitchell.hudson , after remove the @ , the error message is “SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed”

It turns out that the I did not add CA certs into my php.ini file and the problem is solved.

You saved my days, thank you very much . 😃 😃