Postman Wordpress API

Could someone provide guidance on how I might use the Wordpress API and Postman? Our client wants content from a Jewelers website displayed on their site. I have a rough idea of how it should be done but I could not find any references online for what I am doing.

Edit: I want to make read the data from their source into tables that will list the products with images.

Edit 2: I've been messing around with the Wordpress API and Postman and have developed a elementary understanding of it, how can I transfer data from my data source onto my site? And how can I do this without having to update the database?

Posted Aug 13, 2018, 6:09 PM UTC · edited

29
erikteichmannDeveloper•

I'd fetch the data in a shortcode function, store it in a transient as a cache. Use wp_remote_get() to fetch the data.

2
tonylstewart•

How are you pulling the data from their source? Does the jeweler have an API?

About how many products are you pulling in?

2
MutedBoxOP•

I am using a plugin called JSONContentImporter, I've been given the access to the API. I've found some success, I was able to pull multiple results, but I'm having trouble accessing an array within an array.

https://imgur.com/a/byOyOih

https://json-content-importer.com/examples/jci-parser-castlist-json-example/ here the developer demonstrated how to access certain elements of his list... Am I missing something? Is there a better way to do this? I will be pulling 900+ products

Edit: this is my code

{subloop-array:data:-1}

{subloop:data.0:-1}

{subloop-array:data.0:images-1}

{data.0:images.0}

{/subloop-array:data.0.images}

{/subloop:data.0}

{/subloop-array:data}

1
tonylstewart•

ent wants content from a Jewelers website displayed on their site. I have a rough idea of how it should be done but I could not find any references online for what I am doing.

Edit: I want to make read th

With 900+ products, best practice would be to save response in the database so reduce requests. I would create a custom post type with all the data you need.

Reference:

https://codeable.io/how-to-import-json-into-wordpress/

https://wordpress.stackexchange.com/questions/211908/importing-third-party-json-feed-as-custom-post-type/211972#211972

https://wordpress.stackexchange.com/questions/213214/integrate-product-feed-api-in-woocommerce

If you still want to use that plugin, it looks like this page has something about accessing arrays:

https://json-content-importer.com/documentation/subloops-objects-and-arrays/

2
MutedBoxOP•

So basically I need to get the JSON data for ALL of the items, then organize the data and put it into the wordpress database?

1
tonylstewart•

Yes.

How often does the product feed change?

Another solution that would require less code would be to import the jeweler's product feed into Woocommerce and modify woocommerce for your client's requirements.

1
imguralbumbot•

^(Hi, I'm a bot for linking direct images of albums with only 1 image)

https://i.imgur.com/gdUJLEk.png

^^Source ^^| ^^Why? ^^| ^^Creator ^^| ^^ignoreme ^^| ^^deletthis

1
tonylstewart•

Your problem inspired me to write a blog post that could help you out:

https://wordpresswoes.com/consume-restful-api-and-process-in-wordpress-using-etsy-api/

2
saud_razzak•

Getting access token

Connecting Postman to your WordPress is the first step in gaining an access token.

  1. Set the method to “POST“.
  2. Enter your website URL along with “/oauth/token/“. Example: r/https://your-domain.com/oauth/token/
  3. Click on the “Authorization” tab and selected “Basic Auth” from the drop down. Use the client id as the username and client secret as the password and click “Update Request“. This will add a header to the request. Alternatively to sending a Basic Auth header, you can can pass “client_id” and “client_secret” as body parameters .
  4. Click on the “Body” tab and choose “x-www-form-urlencoded” in the radio button selection.
  5. Add “grant_type” as key and “password” as the value.
  6. Add “username” as key and “your username for WP” as the value.
  7. Add “password” as key and “your password for username in WP”.
  8. Click “Send“.

The return from WP OAuth Server will be JSON and include a response and a header code with 200 OK or 401 Unauthorized.

1