Answer the question
In order to leave comments, you need to log in
How to get JSON response into a variable?
The response to the request comes in this form:
"message": {
"headers": {
"to": "",
"message-id" : "[email protected]",
"from": "John Doe ",
"subject " : "Test Subject"
$subject = $dok2[$i]->message->headers->subject; - everything is fine here
$message-id = $dok2[$i]—>message->headers->message-id; - it doesn't work here,
writes an error:
Notice: Undefined property: stdClass::$message in /home........
Notice: Use of undefined constant id - assumed 'id'....
it is id separately from message sees because of the hyphen in the message-id name.
How to fix? This is not stored in a variable.
Answer the question
In order to leave comments, you need to log in
$messageId = $dok2[$i]—>message->headers->{'message-id'}
json_decode($data, true)
$messageId = $dok2[$i]['message']['headers']['message-id']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question