I'm using Wordpress as a backend for my Ionic application.
I get all the data I want from my GET request, however I have a "like" system on my website that I would like to implement everytime a user clicks on it, whether he is authenticated or not.
I really don't get how I can update the field based on WP API.
I've set Basic Authentication on my .htaccess, and every time I make a POST request I get rest-cannot-update error.
Here is how the JSON looks like
[
{
"metadata": {
"_edit_lock": [
"1531733011:13"
],
"_edit_last": [
"13"
],
"onesignal_meta_box_present": [
""
],
"onesignal_send_notification": [
""
],
"slider": [
"1"
],
"_post_like_count": [
"2"
],
}
]
Thank you
Related
Is that possible to update the inventory/stock quanitity in bulk using WooCommerce API? From the documentation for every update we may need to call PUT /wp-json/wc/v3/products/. We have more than 1000 products, it is very inefficiency to call 1000+ api just to update the quatity?
If there is any other thoughts, please welcome to share. Thanks
You can use this endpoint wp-json/wc/v3/products/batch
{
"Update": [
{
"Id": "39",
"Default_attributes": [
{
"Id": null,
"Name": null,
"Sku": "NEW-SKU",
"StockQuantity": "5"
}
]
}
]
}
here is an example body
Hello I cannot manage to upload videos on linkedIn member account using V2 API
I followed the instructions described at the official page
the steps to upload a video (under 200 MB) are
Register an upload for Video
Upload the video
Check status of upload
they all worked , and the last step gives back a successful respose
{
"serviceRelationships": [
{
"identifier": "urn:li:userGeneratedContent",
"relationshipType": "OWNER"
}
],
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"mediaTypeFamily": "STILLIMAGE",
"created": 1583915898789,
"lastModified": 1583916648095,
"id": "C4D22AQELBNtjd0NB2Q",
"status": "ALLOWED"
}
but the video is not displayed in the linked in account page..
I thought it needs to be shared as for the image, but the ugcPosts API does not work..
is this still a closed feature by LinkedIn?
if so how can it be granted?
Any suggestion is higly appreciated!
Hey as stated in the documentation you can use uploaded assets with their corresponding asset urn in ugcPosts (videos) or shares (images).
What got my attention in your question you register a video upload and get back
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"mediaTypeFamily": "STILLIMAGE",
This indicates to me that you used the wrong recipe in the registerUpload request. It should be urn:li:digitalmediaRecipe:feedshare-video
I like to use curl to fetch data from my application insights but i'm unable to get the data from customDimensions (which contains json data). A simple query would be this one:
curl "https://api.applicationinsights.io/v1/apps/my-app-id/query?query=traces%20%7C%20project%20customDimensions" -H "x-api-key: my-api-key"
Let's assume the traces table contains 10 entries then the response would look like this:
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "customDimensions",
"type": "dynamic"
}
],
"rows": [
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ]
]
}
]
}
Using the query editor in application insights in the azure portal, the same query works fine and returns the customDimensions.
Thanks in advance.
Could you please check the application insights you used in your curl query is the same one you did in query editor in azure portal?
I test it at my side, no problem.
Can you try this portal to query application insight from cURL-
https://dev.applicationinsights.io/apiexplorer/query.
In the Request tab choose cURL and in the query tab just write traces | project customDimensions. It worked for me.In that way you can be sure that querying from cURL will work.
Is there any option to get different type response for WordPress single Post and Posts list?
My target for posts list response as
[
{"id":1,
"date":"2017-08-20T07:26:55",
"link":"http://localhost/wordpress/2017/08/20/test-post",
"title":{"rendered":"Test post"}
},
{"id":2,
"date":"2017-08-20T07:26:55",
"link":"http://localhost/wordpress/2017/08/20/test-post",
"title":{"rendered":"Test post"}
},
{"id":3,
"date":"2017-08-20T07:26:55",
"link":"http://localhost/wordpress/2017/08/20/test-post",
"title":{"rendered":"Test post"}
},
{"id":4,
"date":"2017-08-20T07:26:55",
"link":"http://localhost/wordpress/2017/08/20/test-post",
"title":{"rendered":"Test post"}
}
]
For single post response as
{
"id": 92,
"date": "2017-08-20T07:13:42",
"date_gmt": "2017-08-20T07:13:42",
"guid": {
"rendered": "http://devel8/wp-news/?p=1"
},
"modified": "2017-08-20T07:13:42",
"modified_gmt": "2017-08-20T07:13:42",
"slug": "hello-world-2",
"status": "publish",
"type": "post",
"link": "http://localhost/wordpress/2017/08/20/hello-world-2/",
"title": {
"rendered": "Hello world!"
},
"content": {
"rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n",
"protected": false
},
"excerpt": {
"rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n",
"protected": false
},
"author": 1,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
1
],
"tags": [],
.....
.....
}
}
Note: using register_rest_field() and rest_prepare_post filter we can modify the response for both (single and multiple posts) But we need separately response.
OR
There is any option to know the request is made for multiple posts or single post in the get_callback function of register_rest_field().
Thanks in advance.
Since i don't get any response and solution from any one, so i had decided to develop a WordPress plugin which will meet my requirement to handle WP REST API request response for single post and posts list or multiple posts or loop of post or group of posts differently and admin can control from back end.
After long struggle i have developed the plugin named as
One Call – WP REST API Extension
Core features of plugin are
Custom and back end control rest api prefix such as ‘test-api’ where
‘wp-json’ is default to initially secure the api call.
Get different reponse for list posts and single post responses.
For posts list (multiple) call, you can control ‘one_call’ fields
from back end.
WordPress Posts fields filtering options from back end for posts list
(loop of Posts).
Hope this plugin help others like me who has plan to develop mobile application for WordPress Website using Ionic, Phonegap,React Native, Framework& and NativeScript etc.
could you please give me a hint on how to share a single event via google calendar api?
That is I'd like to invite other users to see the event programmatically without sharing the whole calendar. To mimic the "Add guests" UI action
As Claudio mentioned, you need to use the Google Calendar Advanced API for this.
You'll want to use a patch because you don't want to replace all the other data on the calendar invite. However, even in the case of patch, since the attendees lives in an array, if you attempt to pass a patch such as this:
{
attendees: [ { email: "new#example.com"} ]
}
... it'll replace all old invitees (i.e. it'll remove anyone that was on the invite before you called patch). To fix this, you must first get the current invitees, add a new person to the array, and then send a patch.
You can see a detailed example of this in this answer which also explains how to use Google Apps Scripting to ensure an email is sent to the user when adding them to a calendar event (see the addGuestAndSendEmail() method in that post).
You can use the API to add people to the attendees collection:
https://developers.google.com/google-apps/calendar/v3/reference/events/update
refer the following request.
method: POST
endpoint: https://www.googleapis.com/calendar/v3/calendars/primary/events?sendUpdates=all
here, sendUpdates means when you add any guest so he would get an invitation mail used based on scenario.
Input Json:
{
"kind": "calendar#event",
"etag": "etag",
"status": "confirmed",
"summary": "JayKara",
"description": "eqwbdjhwhhwhhwrhjehrhejhfj",
"location": "America",
"creator": {
"email": "#mail.com",
"self": true
},
"organizer": {
"email": "#mail.com",
"self": true
},
"start": {
"date": "2019-12-23"
},
"end": {
"date": "2019-12-24"
},
"originalStartTime": {
"date": "2019-12-24"
},
"visibility": "public",
"attendees": [
{
"email": "****#mail.com" //this guys are the guest
}
]
}.
After that there is no patch method required your guest guys will receive an invitation whenever update event
Cheers!