Hey @BostonJames,
first of all - welcome to the community!
Could you expand your question a bit, not exactly sure what the issue is 🙂 .
Greetings.
If there are single quotes or double quotes in my post title or content it doesn’t work. For example:
This is my post title and it works
Vs
This is my post title and it doesn’t work
I tried addslashes() and the various options for json_encode() for quotes but it isn’t working.
Did you try to escape?
Looks like this:
$content = "This isn\\'t working";
Hey @BostonJames - could you try the example @TMNXT-Dev posted above? I think that should do the trick here.
-Daniel
This is very confusing. This works:
$content = 'This wasn\\'t posting to Monday.com before.';
$query = '
mutation {
create_update (item_id: '.$ticket['monday_board_id'].', body: "'.$content.'") {
id
}
}';
But this does not:
$content = addslashes($input['content']);
$query = '
mutation {
create_update (item_id: '.$ticket['monday_board_id'].', body: "'.$content.'") {
id
}
}';
Even though when I echo this:
$content = addslashes($input['content']);
echo $content;
I get this:
This wasn\\'t posting to Monday.com before.
Hey @BostonJames - stepping back a bit I think we can skip the addslashes
method all together.
Using our PHP quickstart as a baseline, I made a few modifications which allowed me to upload updates through the GraphQL API without any hiccups.
In this example I’m using the $input
variable since I was manually entering different variables on the terminal, but you can replace it for a pre-determined string. The biggest change was declaring the variables on the query portion of the query so that json_encode
would be able to process it.
echo "What do you want to input? ";
$input = rtrim(fgets(STDIN));
$query = 'mutation ($myUpdate: String!) { create_update (item_id: xxxx, body:$myUpdate) {id}}';
$vars = ='myUpdate' => $input];
And then you would just need to modify the last line of the $data portion to json_encode / send your variables as well as the query:
'content' => json_encode(e'query' => $query, 'variables' => $vars])
Let me know if this helps!
-Daniel
That did the trick, thank you!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.