Why are my posts content not showing on my admin dashboard? - wordpress

I have added an application to my WordPress site with a plug in that am using to automatically add posts with a python scripts. My API is working just fine even after testing on postman.
However the post Meta Desc and Key Phrase columns don't show anything as in a post added manually. (See screenshot; the first post is the one added via an api). I will appreciate any idea as to why this is.
post = {
'title': question_title,
'status': 'publish',
"content": question,
"type": "post",
"categories": [2],
"focus_keyphrase": question_title,
}
gradeboosts_url = "https://gradeboosts.com/wp-json/wp/v2"
user = 'aloy'
password = '****************'
creds = user + ':' + password
token = base64.b64encode(creds.encode())
headers = {'Authorization': 'Basic ' + token.decode('utf-8')}
r = requests.post(gradeboosts_url + '/posts', json=post, headers=headers)
A full postman get request that is displaying all columns on wordpress:
response = {
"id": 1692997,
"date": "2021-08-13T12:43:38",
"date_gmt": "2021-08-13T12:43:38",
"guid": {
"rendered": "https://gradeboosts.com/health-sciences-homework-help-3/"
},
"modified": "2021-08-13T12:43:38",
"modified_gmt": "2021-08-13T12:43:38",
"slug": "health-sciences-homework-help-3",
"status": "publish",
"type": "post",
"link": "https://gradeboosts.com/health-sciences-homework-help-3/",
"title": {
"rendered": "Health Sciences homework help"
},
"content": {
"rendered": "<p>Health Sciences homework help. An ion is an atom that has gained or lost one or more electrons.</p>\n<p> I don’t think that this is maths, but more chemistry.<br />\nAn ion is an atom that has a charge due to a lost or gain of electrons. Usually, ions occur when the atom tries to get a full outershell, either by losing electrons (and thus gaining a positive charge) or by gaining electrons (and thus getting a negative charge).</p>\n<p>Health Sciences homework help</p>\n",
"protected": false
},
"excerpt": {
"rendered": "<p>What’s an ion?</p>\n",
"protected": false
},
"author": 2,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": {
"spay_email": ""
},
"categories": [],
"tags": [],
"yst_prominent_words": [],
"jetpack_featured_media_url": "",
"_links": {
"self": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/posts/1692997"
}
],
"collection": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/users/2"
}
],
"replies": [
{
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/comments?post=1692997"
}
],
"version-history": [
{
"count": 190,
"href": "https://gradeboosts.com/wp-json/wp/v2/posts/1692997/revisions"
}
],
"predecessor-version": [
{
"id": 1698135,
"href": "https://gradeboosts.com/wp-json/wp/v2/posts/1692997/revisions/1698135"
}
],
"wp:attachment": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/media?parent=1692997"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/categories?post=1692997"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/tags?post=1692997"
},
{
"taxonomy": "yst_prominent_words",
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/yst_prominent_words?post=1692997"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}

Related

Wordpress ACF fields not showing or letting me update them on POST request

I am trying to create an application. I created a custom post type and added custom fields using ACF. When I try to post to save the data, it doesn't save it and when I create one inside wordpress and request it using it's ID, it doesn't show the data in the response.
Below is the JSON (I tried with acf, fields and with leaving everything outside of an object), response and URL.
{
"title": "title 7",
"acf": {
"feeling": "ok",
"feeling_at_the_moment": "relieved",
"what_have_you_been_doing": "chores",
"cognitive_distortions": "",
"challenge": "",
"interpretation": "",
"feeling_now": "",
"email": "gmail.com"
}
}
{
"id": 4392,
"date": "2022-12-03T19:49:14",
"date_gmt": "2022-12-03T19:49:14",
"guid": {
"rendered": "/?post_type=mood_tracker&p=4392",
"raw": "/?post_type=mood_tracker&p=4392"
},
"modified": "2022-12-03T19:49:14",
"modified_gmt": "2022-12-03T19:49:14",
"password": "",
"slug": "",
"status": "draft",
"type": "mood_tracker",
"link": "/?post_type=mood_tracker&p=4392",
"title": {
"raw": "title 7",
"rendered": "title 7"
},
"content": {
"raw": "",
"rendered": "",
"protected": false,
"block_version": 0
},
"featured_media": 0,
"template": "",
"meta": {
"_mi_skip_tracking": false
},
"permalink_template": "/mood_tracker/%pagename%/",
"generated_slug": "title-7",
"_links": {
"self": [
{
"href": "/wp-json/wp/v2/mood_tracker/4392"
}
],
"collection": [
{
"href": "/wp-json/wp/v2/mood_tracker"
}
],
"about": [
{
"href": "/wp-json/wp/v2/types/mood_tracker"
}
],
"wp:attachment": [
{
"href": "/wp-json/wp/v2/media?parent=4392"
}
],
"wp:action-publish": [
{
"href": "/wp-json/wp/v2/mood_tracker/4392"
}
],
"wp:action-unfiltered-html": [
{
"href": "/wp-json/wp/v2/mood_tracker/4392"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
https://link.com/wp-json/wp/v2/mood_tracker
As per the ACF document. Make sure this is turned on
Make sure you do the same while you are creating the custom field group in case it overwrites the general settings
Sometimes I need to republish the already created posts so they get affected

How to get the register device name from OKTA API

I have a requirement to display the OKTA register device name on the screen like the OKTA does for you.
In the picture above it display (Pixel 2 XL) where is the OKTA API to get the register device name
I am referring to OKTA dev API but didn't found anywhere
https://developer.okta.com/docs/reference/api/factors/
Any idea where can I find ???
Once you have the userid you can call the factors list API to get the enrolled MFA factors for the user.
Which will get you back a body like:
[
{
"id": "opffxq5v54xO5kdsa0x6",
"factorType": "push",
"provider": "OKTA",
"vendorName": "OKTA",
"status": "ACTIVE",
"created": "2020-05-07T20:49:49.000Z",
"lastUpdated": "2020-05-20T13:33:58.000Z",
"profile": {
"credentialId": "test#test.com",
"deviceType": "SmartPhone_Android",
"keys": [
{
"kty": "RSA",
"use": "sig",
"kid": "default",
"e": "AQAB",
"n": "j_rlzlG07lZy_TegQPjllleeaGxxDsrtFNaoQHhDowV1z54okXdDobyJo5B9rcCkP7-i0EniNdaCFDj8xugG7WSmcDRzr46AujT7nFVPI5Z7EZE9IaLdYLP0Hg0nRaC3qhHPdv8JGszle8t0Fej1eR-AqT1mrsNUM3-k44_Axj47xhAkIPoxCjyvvA8W1FWKQbECe_y-HtlcLksJlW03WDt_bCdKwx2uVqca1yiEIF3HwhHtpK1dfwosjyEvfpTtsUWtKJVsJiksLajDhu9dGN3JcOT9unsLbWcyWc-kfQ9_oiaMikZCvtbONGSgVjtBttc95-8CHMw-tpA4HCRlcw"
}
],
"name": "Pixel 4 XL",
"platform": "ANDROID",
"version": "29"
},
"_links": {
"self": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/opffxq5v54xO5kdsa0x6",
"hints": {
"allow": [
"GET",
"DELETE"
]
}
},
"verify": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/opffxq5v54xO5kdsa0x6/verify",
"hints": {
"allow": [
"POST"
]
}
},
"user": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6",
"hints": {
"allow": [
"GET"
]
}
}
}
},
{
"id": "ostgppjgvFiLfBv850x6",
"factorType": "token:software:totp",
"provider": "OKTA",
"vendorName": "OKTA",
"status": "ACTIVE",
"created": "2020-05-20T13:33:58.000Z",
"lastUpdated": "2020-05-20T13:33:58.000Z",
"profile": {
"credentialId": "test#test.com"
},
"_links": {
"self": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/ostgppjgvFiLfBv850x6",
"hints": {
"allow": [
"GET",
"DELETE"
]
}
},
"verify": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/ostgppjgvFiLfBv850x6/verify",
"hints": {
"allow": [
"POST"
]
}
},
"user": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6",
"hints": {
"allow": [
"GET"
]
}
}
}
}
]
The device information is shown under the factorProfile (profile.name) which is documented here but doesn't show an example of push.

Decoding Nested JSON Elements (SwiftUI)

I am trying to parse the JSON data below into the structs that are shown. I am having a helluva time trying to figure out how to get at the "nested" elements, such as elements "title:", "content:", and "excerpt:". Whenever the code runs, it barfs while parsing the nested elements.
I've looked at the Apple Developer stuff and reviewed the Playground here: https://developer.apple.com/documentation/foundation/archives_and_serialization/using_json_with_custom_types
I also tried using quicktype.io to create the data models from the sample JSON, however, in the header of the exported file from quicktype it has the line: "let blogItem = try? newJSONDecoder().decode(BlogItem.self, from: jsonData)", however, I get a compile error that jsonData is not recognized and I'm not able to find any reference to it.
struct BlogSection: Codable, Identifiable {
var id: Int
var slug: String
var link: String
var title: [BlogTitle]
var content: [ContentData]
}
struct BlogTitle: Codable, Equatable, Identifiable {
var id: UUID
var rendered: String
}
struct ContentData: Codable, Identifiable{
var id: UUID
var rendered: String
}
/**************** JSON Data ***************/
[
{
"id": 10960,
"date": "2019-10-02T01:00:07",
"date_gmt": "2019-10-02T05:00:07",
"guid": {
"rendered": "example.com/blog-template-copy-copy/"
},
"modified": "2019-09-20T07:08:41",
"modified_gmt": "2019-09-20T11:08:41",
"slug": "relationships-matter",
"status": "publish",
"type": "post",
"link": "example.com/relationships-matter/",
"title": {
"rendered": "Relationships Matter"
},
"content": {
"rendered": "<h1>Page content</h1>",
"protected": false
},
"excerpt": {
"rendered": "<p>By: Joe Schmoe<br />\nFirst Author",
"protected": false
},
"author": 57,
"featured_media": 10958,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
613
],
"tags": [],
"_links": {
"self": [
{
"href": "example.com/wp-json/wp/v2/posts/10960"
}
],
"collection": [
{
"href": "example.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "example.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "example.com/wp-json/wp/v2/users/57"
}
],
"replies": [
{
"embeddable": true,
"href": "example.com/wp-json/wp/v2/comments?post=10960"
}
],
"version-history": [
{
"count": 5,
"href": "example.com/wp-json/wp/v2/posts/10960/revisions"
}
],
"predecessor-version": [
{
"id": 10971,
"href": "example.com/wp-json/wp/v2/posts/10960/revisions/10971"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "example.com/wp-json/wp/v2/media/10958"
}
],
"wp:attachment": [
{
"href": "example.com/wp-json/wp/v2/media?parent=10960"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "example.com/wp-json/wp/v2/categories?post=10960"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "example.com/wp-json/wp/v2/tags?post=10960"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
]
'
In the JSON you do not have arrays for title and content, so just remove the brackets
struct BlogSection: Codable, Identifiable {
var id: Int
var slug: String
var link: String
var title: BlogTitle
var content: ContentData
}
struct BlogTitle: Codable, Equatable, Identifiable {
var id: UUID
var rendered: String
}
struct ContentData: Codable, Identifiable{
var id: UUID
var rendered: String
}
Title and Content are not Arrays in the json provided so should be declared as entities. Your BlogTitle and ContentData are declared as Identifiable and have a variable for id, but both do not have an id in the json provided, so you will get a decoding error because of that as well.
The error you are getting points to a completely different problem though. How is your jsonData declared?

Wordpress API V2 does not embed items when query parameter is passed

Per the documentation:
Optionally, some linked resources may be included in the response to
reduce the number of HTTP requests required. These resources are
“embedded” into the main response.
Embedding is triggered by setting the _embed query parameter on the
request. This will then include embedded resources under the _embedded
key adjacent to the _links key. The layout of this object mirrors the
_links object, but includes the embedded resource in place of the link
properties.
Despite this, when I make the following GET request:
http://anawins.com/wp-json/wp/v2/posts/2986?_embed
The resulting JSON is identical the request without ?_embed.
With embed:
{
"id": 2986,
"date": "2016-05-09T03:00:42",
"date_gmt": "2016-05-09T07:00:42",
"guid": {
"rendered": "http:\/\/anawins.com\/?p=2986"
},
"modified": "2016-05-08T16:37:39",
"modified_gmt": "2016-05-08T20:37:39",
"slug": "the-secret-to-speaking-with-more-grace",
"type": "post",
"link": "http:\/\/anawins.com\/the-secret-to-speaking-with-more-grace\/",
"title": {
"rendered": "The Secret to Speaking With Grace"
},
"content": {
"rendered": "<p><img class=\"aligncenter size-large wp-image-3474\" src=\"http:\/\/anawins.com\/wp-content\/uploads\/2016\/05\/the-secret-to-speaking-with-grace-367x550.png\" alt=\"Do you...."
},
"excerpt": {
"rendered": "<p>I have a little..."
},
"author": 2,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "standard",
"categories": [193, 58],
"tags": [110, 194, 206, 205, 204],
"better_featured_image": null,
"_links": {
"self": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986"
}],
"collection": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts"
}],
"about": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/types\/post"
}],
"author": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/users\/2"
}],
"replies": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/comments?post=2986"
}],
"version-history": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986\/revisions"
}],
"wp:attachment": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/media?parent=2986"
}],
"wp:term": [{
"taxonomy": "category",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/categories?post=2986"
}, {
"taxonomy": "post_tag",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/tags?post=2986"
}],
"curies": [{
"name": "wp",
"href": "https:\/\/api.w.org\/{rel}",
"templated": true
}]
}
}
Without _embed:
{
"id": 2986,
"date": "2016-05-09T03:00:42",
"date_gmt": "2016-05-09T07:00:42",
"guid": {
"rendered": "http:\/\/anawins.com\/?p=2986"
},
"modified": "2016-05-08T16:37:39",
"modified_gmt": "2016-05-08T20:37:39",
"slug": "the-secret-to-speaking-with-more-grace",
"type": "post",
"link": "http:\/\/anawins.com\/the-secret-to-speaking-with-more-grace\/",
"title": {
"rendered": "The Secret to Speaking With Grace"
},
"content": {
"rendered": "<p><img class=\"aligncenter size-large wp-image-3474\" src=\"http:\/\/anawins.com\/wp-content\/uploads\/2016\/05\/the-secret-to-speaking-with-grace-367x550.png\" alt=\"Do you struggle..."
},
"excerpt": {
"rendered": "<p>I have a little..."
},
"author": 2,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "standard",
"categories": [193, 58],
"tags": [110, 194, 206, 205, 204],
"better_featured_image": null,
"_links": {
"self": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986"
}],
"collection": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts"
}],
"about": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/types\/post"
}],
"author": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/users\/2"
}],
"replies": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/comments?post=2986"
}],
"version-history": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986\/revisions"
}],
"wp:attachment": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/media?parent=2986"
}],
"wp:term": [{
"taxonomy": "category",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/categories?post=2986"
}, {
"taxonomy": "post_tag",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/tags?post=2986"
}],
"curies": [{
"name": "wp",
"href": "https:\/\/api.w.org\/{rel}",
"templated": true
}]
}
}
How do I change the query to make this work?

Open graph fitness.runs returning no data

I have a bunch of Nike+ run data which i'm assuming (based on the below article) is published to the open graph. It certainly looks that way in my timeline.
https://developers.facebook.com/blog/post/2012/08/29/early-success-stories--fitness-and-open-graph/
Frustratingly while my music.listens request works fine and returns all of my Spotify listens, my request for fitness.runs returns no data. Is this simply because Nike haven't integrated correctly with the Open Graph. Or perhaps I need to request extended permissions in my Auth token?
https://developers.facebook.com/docs/reference/opengraph/action-type/fitness.runs
Any ideas?
As with all actions you need the correct permissions, in this case
user_actions.fitness
So the data returned from /me/fitness.runs for Nike will look like
{
"data": [
{
"id": "10101118696330517",
"from": {
"name": "Philippe Harewood",
"id": "13608786"
},
"start_time": "2013-03-22T23:15:56+0000",
"end_time": "2013-03-22T23:26:36+0000",
"publish_time": "2013-03-24T15:50:00+0000",
"application": {
"name": "Nike",
"namespace": "nikeapp",
"id": "84697719333"
},
"data": {
"course": {
"id": "476811255725972",
"url": "http://nikeplus.nike.com/plus/activity/running/detail/2118587303?external_share_id=CE32E1C4-93D8-48A7-A08F-6D5B4C13EE6A&is_new_meta=true",
"type": "fitness.course",
"title": "1.12 miles"
}
},
"type": "fitness.runs",
"no_feed_story": false,
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
},
{
"id": "10101118696155867",
"from": {
"name": "Philippe Harewood",
"id": "13608786"
},
"start_time": "2013-03-19T22:03:32+0000",
"end_time": "2013-03-19T22:18:37+0000",
"publish_time": "2013-03-24T15:49:46+0000",
"application": {
"name": "Nike",
"namespace": "nikeapp",
"id": "84697719333"
},
"data": {
"course": {
"id": "502469216483599",
"url": "http://nikeplus.nike.com/plus/activity/running/detail/2118587302?external_share_id=EBF6BC1D-BDEA-4EE5-B18D-FBC576610F13&is_new_meta=true",
"type": "fitness.course",
"title": "1.49 miles"
}
},
"type": "fitness.runs",
"no_feed_story": false,
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
}
],
"paging": {
"next": "https://graph.facebook.com/13608786/fitness.runs?limit=25&offset=25&__after_id=10101118696155867"
}
}

Resources