Estou tendo um erro quando tento recuperar um campo de um array
.
Segue o json
:
{
"data": {
"messages": [
{
"id": 1,
"sender": "sender@locaweb.com.br",
"recipient": "recipient@locaweb.com.br",
"sent_at": "2015-01-22T18:17:53.586-02:00",
"status": "delivered",
"bounce_code": null,
"subject": "teste"
},
{
"id": 2,
"sender": "sender@locaweb.com.br",
"recipient": "recipient@locaweb.com.br",
"sent_at": "2015-01-22T18:17:53.686-02:00",
"status": "bounced",
"bounce_code": "5.1.1",
"subject": "test2"
}
]
},
"links": {
"self": "http://api.smtplw.locaweb.com.br/v1/message_reports?end_date=2015-04-10&page=2&per=2&start_date=2015-01-01&status=all",
"next": "http://api.smtplw.locaweb.com.br/v1/message_reports?end_date=2015-04-10&page=3&per=2&start_date=2015-01-01&status=all",
"prev": null,
"first": "http://api.smtplw.locaweb.com.br/v1/message_reports?end_date=2015-04-10&page=1&per=2&start_date=2015-01-01&status=all",
"last": "http://api.smtplw.locaweb.com.br/v1/message_reports?end_date=2015-04-10&page=5&per=2&start_date=2015-01-01\u0026status=all"
}
}
Meu PHP esta assim:
$jsonObj = json_decode($VARIAVEL_COM_O_JSON);
$resposta = $jsonObj->data;
foreach ($resposta as $c) {
echo "$c->recipient<br>";
}
O erro que ocorre:
Notice: Trying to get property of non-object in /Library/WebServer/Documents/teste.php on line 24
Linha do erro:
echo "$c->recipient<br>";
Preciso escrever todos os campos recipient
do array
?