Adding a REST API validatation to Wordpress Contact Form 7 - wordpress

I am fairly new to WP programming and not that skill with backend work.
A client recently asked to add an API to the current form they have on their website. We are using the Contact Form 7 plugin for submissions.
Below is the REST API they sent over to add to the form. I am unsure how to place the code to the form.
Any guidance is greatly appreciated.
Web Service Type: REST
Endpoint: https://api.anasight.com/emive
Method: POST
Encoding: application/json
API KEY must be passed in header named ‘x-api-key’
Concurrency limits: 500 requests / sec
Data Model:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "PersonLite",
"type": "object",
"required": [ "email","ip","regdttm","sourceurl","flex1" ],
"properties": {
"email": {
"type": "string",
"description": "The person's email address."
},
"ip": {
"type": "string",
"description": "The person's IP address captured at registration."
},
"regdttm": {
"type": "string",
"description": "The timestamp when the person registered to receive emails."
},
"sourceurl": {
"type": "string",
"description": "The url of the site that collected the registration."
},
"firstname": {
"type": "string",
"description": "The person's first name."
},
"lastname": {
"type": "string",
"description": "The person's last name."
},
"city": {
"type": "string",
"description": "The person's city."
},
"state": {
"type": "string",
"description": "The person's state."
},
"zip": {
"type": "string",
"description": "The person's ZIP code."
},
"listid": {
"type": "string",
"description": "The listid from the publisher."
},
"flex1": {
"type": "string",
"description": "Please send value of E for emive records and M for Myza records"
}
}
}
Sample CURL request:
curl --silent --show-error -H "Accept: application/json" -H "Content-Type: application/json" -H "x-api-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" --data '{"firstname":"Joe","lastname":"Johnson","email":"joe#example.com","city":"Roswell","state":"NM","zip":"12345-6789","ip":"127.0.0.1","regdttm":"2021-05-11 14:25:00","sourceurl":"sendmegreatoffers.com"}' https://api.anasight.com/emive

Related

TVRP API Authorization

I have successfully created an Bearer Token and i would like to request data from the Tour Planning/VRP API. However, i always get the following response: { "error": "Forbidden", "error_description": "These credentials do not authorize access" }
If i try to make the request with the APIKey instead of the Bearer Token, I don't get autenthification.
Authorization by token and apikey work fine for me, I have used it at the same time in other methods and it works fine. But none of these two authorization methods works:
POST https://vrp.api.here.com/v1/problems
Authorization: Bearer <My_Token>
or
POST https://vrp.api.here.com/v1/problems?apikey=My_ApiKey
with this Body:
{
"plan": {
"jobs": [
{
"id": "myJob",
"places": {
"delivery": {
"location": {"lat": 52.46642, "lng": 13.28124},
"times": [["2019-07-04T10:00:00.000Z","2019-07-04T12:00:00.000Z"]],
"duration": 180
}
},
"demand": [1]
}
]
},
"fleet": {
"types": [
{
"id": "myVehicle",
"profile": "normal_car",
"costs": {
"distance": 0.0002,
"time": 0.004806,
"fixed": 22
},
"shifts": [{
"start": {
"time": "2019-07-04T09:00:00Z",
"location": {"lat": 52.52568, "lng": 13.45345}
},
"end": {
"time": "2019-07-04T18:00:00Z",
"location": {"lat": 52.52568, "lng": 13.45345}
}
}],
"limits": {
"maxDistance": 300000,
"shiftTime": 28800
},
"capacity": [10],
"amount": 1
}
],
"profiles": [{
"name": "normal_car",
"type": "car",
"departureTime": "2019-07-04T09:15:00Z"
}]
}
}
Thanks Jose
You are probably using your Freemium account, which does not include access to the Tour Planning API at this point. We are working on an update for the developer portal that will make it more clear which APIs are included. If you need access please use the contact us form on the developer portal to reach out to a HERE representative.

Getting all profiles from Google Analytics API

I'm trying to get all profiles using ~all option with this endpoint
https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles
It doesn't return all profiles due to ~all for accounts. If I include account ID instead of ~all, then it returns profiles based on that account id - which are missing when used with ~all option.
https://www.googleapis.com/analytics/v3/management/accounts/89478503/webproperties/~all/profiles
Am I doing something wrong or is this GA API bug?
I sugst you look into using account summaries list
GET https://www.googleapis.com/analytics/v3/management/accountSummaries
This will return all the account information for a user.
{
"kind": "analytics#accountSummaries",
"username": "me#gmail.com",
"totalResults": 15,
"startIndex": 1,
"itemsPerPage": 1000,
"items": [
{
"id": "59183475",
"kind": "analytics#accountSummary",
"name": "Cube Analytics",
"webProperties": [
{
"kind": "analytics#webPropertySummary",
"id": "UA-59183475-1",
"name": "Cube Analytics",
"internalWebPropertyId": "93305066",
"level": "STANDARD",
"websiteUrl": "XXXXXXX",
"profiles": [
{
"kind": "analytics#profileSummary",
"id": "115455750",
"name": "Alaternate",
"type": "WEB"
},
{
"kind": "analytics#profileSummary",
"id": "97191919",
"name": "All Web Site Data",
"type": "WEB"
},
{
"kind": "analytics#profileSummary",
"id": "178538323",
"name": "MobileView",
"type": "APP"
}
]
}, ]
}
By using this call you should only need to make one call and get all of the information back.

How to check domain is verified using Google Analytics API?

I have used analytics.read in order to get user's sites and Google API response is:
{
"kind": "analytics#accountSummaries",
"username": "user#gmail.com",
"totalResults": 1,
"startIndex": 1,
"itemsPerPage": 1000,
"items": [
{
"id": "92159597",
"kind": "analytics#accountSummary",
"name": "MyNewDomain",
"webProperties": [
{
"kind": "analytics#webPropertySummary",
"id": "UA-92159597-1",
"name": "MyNewDomain",
"internalWebPropertyId": "236529827",
"level": "STANDARD",
"websiteUrl": "http://www.example.com",
"profiles": [
{
"kind": "analytics#profileSummary",
"id": "140745434",
"name": "All Web Site Data",
"type": "WEB"
}
]
}
]
}
]
}
Why there is no property related to domain status? How should I check whether domain is verified or not?
I tried to use siteverification scope for Google Verification API, it has the response that I need and it returns the list of verified domains but it has a scope of managing domains, so no one will actually grant access to our application in order to manage their domains and verify/un-verify domains.
Sample response:
{
"id": "string",
"site": {
"type": "string",
"identifier": "string"
},
"owners": [
"string"
]
}
How can I use analytics.read to get verified domains not unverified websites?

In swagger-editor can I control whether to send an empty parameter or not send the parameter

Swagger-editor sends optional array parameters even when they are empty.
Is there a way to specify in Swagger 2.0 to not send the optional parameter if it is an empty array?
The target of the request is intended to be a list of Cats and/or a list of Dogs - neither of which are required.
I was hoping that if the request contains only Cats, the caller would only provide a list of Cats, and not have to also send an empty list of Dogs.
The swagger-editor enforces the empty list.
POST http://example:9090/api/testpath HTTP/1.1
Content-Type: application/json
{
"Dogs": [
1
],
"Cats": []
}
I am not sure whether this would be a valid request.
POST http://example:9090/api/testpath HTTP/1.1
Content-Type: application/json
{
"Dogs": [
1
]
}
This is an example swagger specification
{
"swagger": "2.0",
"info": {
"title": "demo",
"version": "Draft 0.1.0"
},
"host": "example:9090",
"schemes": [
"http",
"https"
],
"basePath": "/api",
"produces": [
"application/json"
],
"paths": {
"/testpath": {
"post": {
"summary": "Request with a complex target\n",
"parameters": [
{
"name": "target",
"in": "body",
"required": true,
"description": "Array of collars and/or mobs to target with this request.",
"schema": {
"$ref": "#/definitions/TargetObjects"
}
}
],
"responses": {
"200": {
"description": "The request was accepted."
}
}
}
}
},
"definitions": {
"TargetObjects": {
"type": "object",
"description": "Target of a request may be one or more objects or different types.\n",
"properties": {
"Dogs": {
"description": "A list of Dogs.",
"type": "array",
"items": {
"type": "number",
"format": "int64"
}
},
"Cats": {
"description": "A list of Pets.",
"type": "array",
"items": {
"type": "number",
"format": "int64"
}
}
}
}
}
}

PingFederate REST API for /sp/adapter not working

PingFederate 8.2.2 is used for our systems.All the REST APIs to create PF objects are automated but /sp/adapter(https://pfhost:9999/pf-admin-api/v1/sp/adapters) is not working using the below JSON .Manually If I create the same configuration it works.The below mentioned JSON is retrieved from already manually created /sp/adapter.But when I use the same JSON in API call which says error as below, please help to solve this problem.
ERROR:
{
"resultId": "validation_error",
"message": "Validation error(s) occurred. Please review the error(s) and address accordingly.",
"validationErrors": [
{
"message": "'' is not a valid selection for 'Send Extended Attributes'",
"fieldPath": "configuration.fields[21].value",
"errorId": "plugin_validation_error"
}
]
}
JSON:
{
"id": "opentokenadapt1",
"name": "opentokenadapt1",
"pluginDescriptorRef": {
"id": "com.pingidentity.adapters.opentoken.SpAuthnAdapter"
},
"configuration": {
"tables": [],
"fields": [
{
"name": "Password",
"value": "Password123"
},
{
"name": "Confirm Password",
"value": "Password123"
},
{
"name": "Transport Mode",
"value": "2"
},
{
"name": "Token Name",
"value": "opentoken"
},
{
"name": "Cipher Suite",
"value": "2"
},
{
"name": "Authentication Service",
"value": ""
},
{
"name": "Account Link Service",
"value": ""
},
{
"name": "Logout Service",
"value": ""
},
{
"name": "Cookie Domain",
"value": ""
},
{
"name": "Cookie Path",
"value": "/"
},
{
"name": "Token Lifetime",
"value": "300"
},
{
"name": "Session Lifetime",
"value": "43200"
},
{
"name": "Not Before Tolerance",
"value": "0"
},
{
"name": "Force SunJCE Provider",
"value": "false"
},
{
"name": "Use Verbose Error Messages",
"value": "false"
},
{
"name": "Obfuscate Password",
"value": "true"
},
{
"name": "Session Cookie",
"value": "false"
},
{
"name": "Secure Cookie",
"value": "false"
},
{
"name": "HTTP Only Flag",
"value": "true"
},
{
"name": "Send Subject as Query Parameter",
"value": ""
},
{
"name": "Subject Query Parameter ",
"value": ""
},
{
"name": "Send Extended Attributes",
"value": ""
},
{
"name": "Skip Trimming of Trailing Backslashes",
"value": "false"
}
]
},
"attributeContract": {
"coreAttributes": [
{
"name": "subject"
}
],
"extendedAttributes": [
{
"name": "nsroles"
}
]
}
}
"Send Extended Attributes" needs a valid value (not the empty string you've given it). The possible values are "0" (None), "1" (Cookies) or "2" (Query Parameters).
One tip in trying to narrow these issues down: try building the SP adapter instance in the PingFederate administrative console (UI) then compare it with the JSON model you GET from the API.

Resources