How to Install Json Api Plugin in worldpress website - wordpress

I am not wordpress developer Basically I have android application template for wordpress website. My client send me a Json Api to upload that file to "/wp-content/plugins/".I am android developer having no exp with server side. so can any one guide what I have to do(I mean what I have to do to access this path).

JSON API WP
You just call recent api plugin like - ...../json=get_recent_posts
*response for the get_recent_post*
{
"status": "ok",
"count": 10,
"count_total": 79,
"pages": 7,
"posts": [
{ ... },
{ ... },
...
]
}
Explicit mode examples:
http://www.example.org/?json=get_recent_posts
http://www.example.org/?json=get_post&post_id=47
http://www.example.org/?json=get_tag_posts&tag_slug=banana
With user-friendly permalinks configured:
http://www.example.org/api/get_recent_posts/
http://www.example.org/api/get_post/?post_id=47
http://www.example.org/api/get_tag_posts/?tag_slug=banana
for details follow this link
https://wordpress.org/plugins/json-api/other_notes/
Rather then json api try new wp rest api 2 which is feature of wp-4.4
http://v2.wp-api.org/
downlaod plugin and install it.
just type /wp-json/wp/v2/posts in end of your site url and you will get all post.
for get all post
www.mysite.com/wp-json/wp/v2/posts
For the search functionality - search test post
/wp-json/wp/v2/posts?filter[s]=test
much more details from this link
http://v2.wp-api.org/reference/posts/
Note for best result use latest version of WP

Related

Enable CORs for Swashbuckle swagger.json in .NET Lambda API

I have a .NET lambda API that I was previously using Swashbuckle to generate a swagger.json file that was given to an external site to use. I am now trying to setup so the swagger.json file is is generated by the API and available through a url for the external site to us ie: mylambdaapi.com/swagger/v2/swagger.json. I was able to get this working by adding a dummy event to my template when pushing to aws as follows.
"SwaggerJson": {
"Type": "Api",
"Properties": {
"Path": "/swagger/v2/swagger.json",
"Method": "GET"
}
}
This works for just accessing the file normally, however the external site will run into CORS "No 'Access-Control-Allow-Origin' header" issues when trying to load the json. Is there any way to force the generation to use "Access-Control-Allow-Origin" in this case? Or is this not feasible in this way? I'm working off what another developer had built previously so I'm trying not to rewrite every, however I'm open to another method as long as it is able to produce some swagger json that the external site can consume.
EDIT: I should note that I am using API gateway, hover the swagger.json is only used for documentation purposes for the external site.
Attempted to use UseCors() functionality however that did not work. I was able to fix the issue by adding an anonymous function to handle the response before UseSwagger.
The following snip-it is from the Configure function in my startup.
app.Use((context, next) =>
{
context.Response.Headers["Access-Control-Allow-Origin"] = "*";
return next.Invoke();
});
app.UseSwagger();

Rest API to get all media from Wordpress Site

I am trying to get all the media from my WordPress site: www.napkinsights.com through the use of a REST API. However, when I go to https://napkinsights.com/wp-json/wp/v2/media, all I receive is an empty array.
So I was wondering, how would I be able to access all the media from my website through an API Call?
REST API will show only those uploaded directly to Media Libary, try it for your self and see it.
If you call media/id/ of the image you will get
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": {
"status": 401
}
}
But If it's an image not attached to post and created directly at Media Libary It will display in REST API.
Your second best option is to directly access via SQL all those images
select * from wp_posts where post_type = 'attachment';

Is there a way to integrate an Expo app with firebase dynamic links without detaching?

Is there a way to integrate an Expo app with firebase dynamic links without detaching.
If you need to create new dynamic links on the fly you could use REST API to do it. In the much more likely scenario that you only need your app to open Firebase's dynamic links, you don't need to do anything other than configuring your Expo App to handle universal links (ie: deeplinks using http/https).
The checklist is something like this:
1. Configure your app.json
For Android, add the intentFilters property to your android property:
"android": {
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"scheme": "https",
"host": "<your-domain>",
"pathPrefix": "/"
},
],
"category": [
"BROWSABLE",
"DEFAULT"
],
"autoVerify": true // required to work on newer android versions
}
]
]
For iOS, add the associatedDomains property to ios:
"ios": {
"associatedDomains": ["applinks:<your-domain>"]
}
2. Configure your domain to allow links from it to be handled by the apps
Android and iOS will allow your app to open links from your domain if you serve a configuration file from a specific location:
Android: https://<your-domain>/.well-known/assetlinks.json
iOS: https://<your-domain>/.well-known/apple-app-site-association
assetlinks.json will look something like this:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "<android-package-name>",
"sha256_cert_fingerprints":
["<your-sha256-certificate-fingerprints>"]
}
}]
And the apple-app-site-association like this:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "<your-team-id>.<ios-bundle-identifier>",
"paths": [ "*" ]
}
]
}
}
You can read more about these files here and here.
To obtain the SHA256 fingerprints of your app’s signing certificate you can use the keytool:
keytool -list -v -keystore <your-key-file>
After you enter your keystore password, it will print many of the keystore information including the SHA256 fingerprints.
If your site is hosted on Firebase both assetlinks.json and apple-app-site-association can be generated automatically if you create the Apps on your Firebase's project. Otherwise, just put these files on the root of your domain.
3. Create a Firebase dynamic link
I think this is step is mostly self explanatory but just a few notes:
Set up your short URL link: in the end you will have / that you send to your users
Set up your Dynamic Link: here you define your deelink (the link you want your app to handle)
Define link behavior for iOS: you mostly likely want to click on 'Open the deep link in your iOS App' and select your App from the list (if you haven't yet, create one App for each platform on your project)
Define link behavior for Android: same as previous but with a few more options to select
Configure (or not) campaign tracking and you're done.
Remember that you always should test your deeplinks by clicking instead of by entering directly on the browser. You may send the link to yourself on the WhatsApp or put on some notes app, for example.
Others resources that might be helpful:
https://docs.expo.io/versions/latest/workflow/linking/
https://reactnavigation.org/docs/deep-linking/
In addition to Pedro Andrade's instructions:
1.) Firebase requires the following details under your app > project settings for dynamic links to work.
Android: SHA 256 (App signing key certificate fingerprint) - this can be retrieved via play store > your app > App Integrity > SHA 256
iOS: App ID Prefix (Team ID): developer.apple.com > Certificates, Identifiers & Profiles > your app id > App ID Prefix
Surprisingly, these are mentioned almost nowhere in the docs, but do come up in stackoverflow results and other answers when googling errors that debugging preview links result in:
Android app '<bundle id>' lacks SHA256. AppLinks is not enabled for the app. Learn more.
iOS app '<bundle id>' lacks App ID Prefix. UniversalLinks is not enabled for the app. Learn more.
You can view debugging preview links by adding ?d=1 to your dynamic links.
https://firebase.google.com/docs/dynamic-links/debug
2.) Even if you use a page.link-style domain provided by firebase for your dynamic links, your associatedDomain/intentFilter domains in app.json should still be your actual domain
i.e if you're generating my-app.page.link shortLinks, that are dynamic links to my-app.com, you should use my-app.com in app.json
Pedro Andrade's solution works! Partially...
Explaining:
You must NOT add your dynamic link domain in intentFilters and associatedDomains, because it makes the app to open the link directly in the app, so, the dynamic link is not processed and you don't have access to the link generated by the dynamic link.
It works partially because of this: the dynamic link needs to be opened by the browser (chrome or safari) before being opened in the app.
Example: Open "<your-domain>.page.link/XLSj" in browser, browser will direct to generated link: "<your-domain>.com/params/54" to configured deep link.
I don't know any other way to 'read' the dynamic link by expo in managed workflow.

How to retrieve member list from Silverstripe API

I am developing a platform and I need to get the members emails from an existing Silverstripe installation. I think it is V4 but not sure yet.
I was hoping to call a REST API but I can't seem to find any information about how you would go about doing this. I would need to call this each day to get the latest members.
Is this possible or is there another way to go about doing this?
I had a look at the API documentation but the information is not helpful and it does not have an explanations or examples. https://api.silverstripe.org/4/index.html
Silverstripe 4 does not expose its data through a REST API service out of the box. We can install a module to allow us to do this.
Rest API module:
https://github.com/colymba/silverstripe-restfulapi
Rest API module:
https://github.com/silverstripe/silverstripe-restfulserver
An alternative is to use the Silverstripe GraphQL module to retrieve data:
https://github.com/silverstripe/silverstripe-graphql
You can do this almost out of the box with the SilverStripe GraphQL API in SilverStripe 4. In addition to 3dgoo's answer, here's a bit of a guide for you:
Out of the box configuration
SilverStripe exposes an "admin" GraphQL server, which requires you to be logged in to use it. If you want to use it from another server, you can base64 encode your basic authentication credentials and pass it as a header. More info on this here.
The SilverStripe CMS module already exposes member's first and last names, since they're used by parts of the CMS through the GraphQL API already. If you want an email address then you can add that with some basic YAML in your app folder.
Adding the member's email field
Add some custom configuration to your app/_config folder - configuration in SilverStripe is merged, so the array values fields: [Email] will merge with the CMS values linked above
# File: app/_config/graphql.yml
---
Name: appgraphql
---
SilverStripe\GraphQL\Manager:
schemas:
admin:
scaffolding:
types:
SilverStripe\Security\Member:
fields: [Email]
operations:
read: true
Note that I've also added operations.read: true to this, because the CMS will only let you read members one at a time via the readOne operation. For your case you'll want to enable read, which returns a paginated list. More info on available operations.
Testing your query
The easiest way to do this is to install GraphiQL (via silverstripe-graphql-devtools), a web (or app) based UI for inspecting GraphQL schemas and running queries against your server. This can be done easily with Composer:
composer require --dev silverstripe/graphql-devtools dev-master
Open up your browser to http://localhost/dev/graphiql?flush. Replace localhost with whatever your SilverStripe server is running on. You add ?flush to the querystring to tell SilverStripe to flush its cache (YAML and PHP files) to pick up your new module and config.
When you get your GraphiQL query editor you can start by writing query GetUsers { ... } and you'll notice that as you type deeper into the query it autocompletes the available options for you.
Here's the query to retrieve your member email addresses:
query GetUserEmails {
readSilverStripeMembers {
edges {
node {
Email
}
}
}
}
Micro-explanation: GetUserEmails is an arbitrary query name you create. You don't actually need to write one, it'll work fine without. readSilverStripeMembers is an automatically scaffolded query name, which happens because you enabled read: true in the GraphQL operations. If you delete it and start typing it again you'll see the other options available as well, the one that ships out of the box with the CMS is readOneSilverStripeMember. The edges and node levels are for pagination.
Using the query
It sounds to me like your SilverStripe server is already running somewhere, and you may not have a local version to test. If that's the case, simply adding the YAML configuration above to your app folder and deploying it will be enough to get your server to give member emails in admin GraphQL calls, then you can do your GraphQL queries with cURL or something:
curl 'http://localhost/admin/graphql/' \ # Adjust to your domain
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \ # This is admin:admin base64 encoded
-H 'Content-Type: application/json' \ # Required for the input data structure
--data-binary '{"query":"query { readSilverStripeMembers { edges { node { Email } } } }","variables":null}'
Example output:
{
"data": {
"readSilverStripeMembers": {
"edges": [
{
"node": {
"Email": "leslie.lawless#example.com"
}
},
{
"node": {
"Email": "mika#example.com"
}
},
{
"node": {
"Email": "sam#example.com"
}
}
]
}
}
}

Apple App Site association not working

App Search API Validation Tool of "Apple" is not validating my domain.
https://search.developer.apple.com/appsearch-validation-tool
I am using universal links but "Link to Application" is showing me "Error".(http://www.awesomescreenshot.com/image/1719847/330979a43c4c6b2766da1e703447ee04)
Here is my "apple-app-site-association" file code.
{"applinks": {"apps": [],"details": {"XXXXXXXXXX.com.streatmanagement.threadshare": {"paths": ["*"]}}}}
Can someone please solve my query or send the sample of "apple-app-site-association" valid code?
Apple's API validation tool compares your website's association file to a store listing. If your app is not yet publicly available the error you listed will be displayed.
Your apple-app-site-association has a small typo where you specify the details (it should be an array). I also assume you're replacing the XXXX's with your app ID.
{
"applinks": {
"apps": [],
"details": [
{
"appID": "APPID.BUNDLEID",
"paths": [ "*" ]
}
]
}
}
Even if you get this error from Apple's validation tool, you can test Universal links. If your Universal Link does not work on your test device you need to inspect the device logs when you fresh install it and make sure your apple-app-site-association is available at the root of your site via https with no redirects. Sometimes there is issue if the content-type is not application/json (but the file name should remain exactly apple-app-site-association).

Resources