News
The News object
The News object looks like this in JSON:
{
"object": "news",
"id": 8,
"title": "New Coffee Shop",
"content": "Check out the new coffee shop in the lobby of the school admin building!",
"publish": true,
"publish_time": "2008-01-29T01:08:56+00:00",
"feature": false,
"feature_until": null,
"allow_comments": true,
"visibility": "all",
"added_at": "2008-01-29T01:08:56+00:00",
"added_by_id": 16,
"updated_at": "2008-02-13T21:57:06+00:00",
"updated_by_id": 16,
"sandbox": true
}
| Attribute | Required | Data Type |
|---|---|---|
| id | No | int |
| title | Yes | text (200) |
| content | Yes | text |
| publish | No | bool |
| publish_time | No | datetime |
| feature | No | bool |
| feature_until | No | date |
| allow_comments | Yes | bool |
| visibility | Yes | enum (all, select) |
| added_at | Yes | datetime |
| added_by_id | No | int |
| updated_at | No | datetime |
| updated_by_id | No | int |
| sandbox | No | bool |
index
Example code to call this method:
curl "https://yourschool.populiweb.com/api2/news" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_POPULI_API_KEY" \
-X GET
-d '{
"filter": {"0":{"logic":"ALL","fields":[{"name":"posted_by","value":{"display_text":"Blah","id":"123"},"positive":1}]}}
}' \
require 'httparty'
response = HTTParty.get(
'https://yourschool.populiweb.com/api2/news',
headers: {
'Authorization' => 'Bearer YOUR_POPULI_API_KEY'
},
)
puts response.body
import requests
response = requests.get(
'https://yourschool.populiweb.com/api2/news',
headers={
'Authorization': 'Bearer YOUR_POPULI_API_KEY'
},
)
print(response.json())
using Newtonsoft.Json;
using RestSharp;
var client = new RestClient();
var request = new RestRequest(new Uri("https://yourschool.populiweb.com/api2/news"), Method.Get);
request.AddHeader("Authorization", "Bearer YOUR_POPULI_API_KEY");
var response = client.Execute(request);
var response_object = JsonConvert.DeserializeObject(response.Content);
Console.Write(response_object);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://yourschool.populiweb.com/api2/news');
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_POPULI_API_KEY']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
$response = curl_exec($curl);
$response_decoded = json_decode($response);
var_dump($response_decoded);
Example response:
{
"object": "list",
"count": 1,
"results": 1,
"results_per_page": 200,
"pages": 1,
"page": 1,
"offset": 0,
"has_more": false,
"data": [
{
"object": "news",
"id": 8,
"title": "New Coffee Shop",
"content": "Check out the new coffee shop in the lobby of the school admin building!",
"publish": true,
"publish_time": "2008-01-29T01:08:56+00:00",
"feature": false,
"feature_until": null,
"allow_comments": true,
"visibility": "all",
"added_at": "2008-01-29T01:08:56+00:00",
"added_by_id": 16,
"updated_at": "2008-02-13T21:57:06+00:00",
"updated_by_id": 16,
"report_data": {
"author_name": "Abby Admin",
"campus_names": null,
"article_views": 0
}
}
],
"sandbox": true
}
Retrieves all News objects that match given filter conditions.
HTTP Request
GET /news
Parameters
| Name | Required | Data Type | Description |
|---|---|---|---|
| filter | No | mixed | See available filter conditions |
| page | No | int | The page of results to return if more than 200 records are found. |
Expandable Properties
- comments
- likes
- campuses
- roles
- files
- news_reads
Filter Condition Parameters
These conditions can be used to narrow the results returned.
| Name | Type |
|---|---|
| title | text |
| publish | bool |
| publish_time | datetime |
| feature | bool |
| feature_until | date |
| allow_comments | bool |
| views | integer |
| posted_time | datetime |
| posted_by | object_id |
Permissions
One of the following roles is required to call this method:
- Staff
show
Example code to call this method:
curl "https://yourschool.populiweb.com/api2/news/(news)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_POPULI_API_KEY" \
-X GET
require 'httparty'
response = HTTParty.get(
'https://yourschool.populiweb.com/api2/news/(news)',
headers: {
'Authorization' => 'Bearer YOUR_POPULI_API_KEY'
},
)
puts response.body
import requests
response = requests.get(
'https://yourschool.populiweb.com/api2/news/(news)',
headers={
'Authorization': 'Bearer YOUR_POPULI_API_KEY'
},
)
print(response.json())
using Newtonsoft.Json;
using RestSharp;
var client = new RestClient();
var request = new RestRequest(new Uri("https://yourschool.populiweb.com/api2/news/(news)"), Method.Get);
request.AddHeader("Authorization", "Bearer YOUR_POPULI_API_KEY");
var response = client.Execute(request);
var response_object = JsonConvert.DeserializeObject(response.Content);
Console.Write(response_object);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://yourschool.populiweb.com/api2/news/(news)');
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_POPULI_API_KEY']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
$response = curl_exec($curl);
$response_decoded = json_decode($response);
var_dump($response_decoded);
Example response:
{
"object": "news",
"id": 8,
"title": "New Coffee Shop",
"content": "Check out the new coffee shop in the lobby of the school admin building!",
"publish": true,
"publish_time": "2008-01-29T01:08:56+00:00",
"feature": false,
"feature_until": null,
"allow_comments": true,
"visibility": "all",
"added_at": "2008-01-29T01:08:56+00:00",
"added_by_id": 16,
"updated_at": "2008-02-13T21:57:06+00:00",
"updated_by_id": 16,
"sandbox": true
}
Retrieves a specific News object.
HTTP Request
GET /news/(news)
Parameters
No additional parameters are needed beyond the ID of the object being requested that appears in the URL.
Expandable Properties
- comments
- likes
- campuses
- roles
- files
- news_reads
Permissions
One of the following roles is required to call this method:
- Staff