# Can't get data from notifications.json (solved)

**URL:** https://meta.discourse.org/t/cant-get-data-from-notifications-json-solved/71496
**Category:** Support
**Created:** [October 5, 2017, 9:38pm UTC](https://meta.discourse.org/t/cant-get-data-from-notifications-json-solved/71496 "2017-10-05T21:38:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![magoz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/magoz/32/80046_2.png) [@magoz](https://meta.discourse.org/u/magoz)
#### Post date: [October 5, 2017, 9:38pm UTC](https://meta.discourse.org/t/cant-get-data-from-notifications-json-solved/71496/1 "2017-10-05T21:38:01Z")

</div>

I’m trying to get the number of notifications via `/notifications.json` on [https://mysite.com](https://mysite.com)

I’ve enabled CORS in the app.yml file (also allowed [http://mysite.com](http://mysite.com) on Discourse \> Settings \> cors origins).  
I’m already using other .json to retrieve other information and it works perfectly ( `/latest.json`, for example).

Here is my code in PHP, I’m just trying to get one of the objects, to see if I can access to any of the information.

```
$string_notifications = file_get_contents('https://forum.mysite.com/notifications.json');
$json_notifications = json_decode($string_notifications, true);
$notifications_total_number = $json_notifications['total_rows_notifications'];
echo $notifications_total_number;

```

But it doesn’t work. It doesn’t retrieve anything.  
If I go to [https://forum.mysite.com/notifications.json](https://forum.mysite.com/notifications.json) via the browser it works.

Any ideas why is not working? Am I missing something?  
Thanks!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 5, 2017, 11:59pm UTC](https://meta.discourse.org/t/cant-get-data-from-notifications-json-solved/71496/2 "2017-10-05T23:59:02Z")

</div>

I am SUPER confused here, are you properly using the Discourse API and specifying API keys.

Try going to that page as anonymous in chrome, that is what you are doing.

---

<div class="post-metadata">

### Author: ![magoz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/magoz/32/80046_2.png) [@magoz](https://meta.discourse.org/u/magoz)
#### Post date: [October 6, 2017, 8:13am UTC](https://meta.discourse.org/t/cant-get-data-from-notifications-json-solved/71496/3 "2017-10-06T08:13:56Z")

</div>

Thanks for your help, I solved the issue.  
As you pointed, there was a problem related to the API keys, I didn’t pass correctly the username value.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [October 6, 2017, 8:23am UTC](https://meta.discourse.org/t/cant-get-data-from-notifications-json-solved/71496/4 "2017-10-06T08:23:06Z")

</div>


