I have the following JSON Format:
{
"insights": {
"data": [
{
"name": "page_impressions",
"period": "day",
"values": [
{
"value": 2,
"end_time": "2022-05-19T07:00:00+0000"
},
{
"value": 1,
"end_time": "2022-05-20T07:00:00+0000"
}
],
"title": "Daily Total Impressions",
"description": "Daily: The number of times any content from your Page or about your Page entered a person's screen. This includes posts, stories, ads, as well other content or information on your Page. (Total Count)",
"id": "107188788663426/insights/page_impressions/day"
},
{
"name": "page_impressions",
"period": "week",
"values": [
{
"value": 36,
"end_time": "2022-05-19T07:00:00+0000"
},
{
"value": 37,
"end_time": "2022-05-20T07:00:00+0000"
}
],
"title": "Weekly Total Impressions",
"description": "Weekly: The number of times any content from your Page or about your Page entered a person's screen. This includes posts, stories, ads, as well other content or information on your Page. (Total Count)",
"id": "107188788663426/insights/page_impressions/week"
},
{
"name": "page_impressions",
"period": "days_28",
"values": [
{
"value": 36,
"end_time": "2022-05-19T07:00:00+0000"
},
{
"value": 37,
"end_time": "2022-05-20T07:00:00+0000"
}
],
"title": "28 Days Total Impressions",
"description": "28 Days: The number of times any content from your Page or about your Page entered a person's screen. This includes posts, stories, ads, as well other content or information on your Page. (Total Count)",
"id": "107188788663426/insights/page_impressions/days_28"
}
],
"paging": {
"previous": "https://graph.facebook.com/v13.0/107188788663426/insights?access_token=EAAQeCPGNpp4BAIkM5ulDmHe7V98aWaG5Mt4oQZA6x4YuSH1oo1dyucXuk4oPLireHPlqk2jZBuqNxfBC3yVAjNNCxIBv6RsIenz5gG43qZB4O11qp4COndKvkmZC6lEUqCLUz2SeiQ1aWDpe4YYEZC3j83ZAWRKxXAMiRONIuzhZCCDEuXJoGX7ePy6mnHEUURAZAp5tz3OUfz6VQstnlJ8b&pretty=0&metric=page_impressions&since=1652684400&until=1652857200",
"next": "https://graph.facebook.com/v13.0/107188788663426/insights?access_token=EAAQeCPGNpp4BAIkM5ulDmHe7V98aWaG5Mt4oQZA6x4YuSH1oo1dyucXuk4oPLireHPlqk2jZBuqNxfBC3yVAjNNCxIBv6RsIenz5gG43qZB4O11qp4COndKvkmZC6lEUqCLUz2SeiQ1aWDpe4YYEZC3j83ZAWRKxXAMiRONIuzhZCCDEuXJoGX7ePy6mnHEUURAZAp5tz3OUfz6VQstnlJ8b&pretty=0&metric=page_impressions&since=1653030000&until=1653202800"
}
},
"id": "107188788663426"
}
I can iterate over the json data:
for data in test["insights"]["data"]:
print(data["title"])
for val in data["values"]:
for key, value in val.items():
print(f"The value: [ {value} ]")
But I can't figure out how can I POST it to my api. The table structure is as follow: id, total_impressions (day, weekly, 28days), values (changes depending on the day), and the date. Is there a way I can post data to the api in this format:
Page ID -- day -- 5(value) -- date
Page ID -- day -- 6(value) -- date
Page ID -- weekly -- 13(value) -- date
Page ID -- weekly -- 14(value) -- date
Page ID -- 28 -- 67(value) -- date
Page ID -- 28 -- 59(value) -- date
Any help would be appreciated. I'm getting this data from Facebook Graph API.