How to access a table in a WordPress database using REST API?

I have a wordpress database. There are some tables in it.

enter the description of the image here

I want to access the contents of the table wp_fa_user_logins using the REST API Know when a user logged in. I know that I can use SSH in the database or connect to it using an SQL client, but that's not what I need.

API design: Rest API is a better alternative to polling for long-lasting asynchronous tasks

I have created a restplus API bottle that accepts the xlsx file as input and returns an XML. This would be consumed internally by our different APIs.

The current flow:

  1. Users POST an xlsx file by calling / uploading endpoint.

  2. API accepts the file, stores it and returns a file ID.

  3. The user sends / executes another request by providing the identification of the file for processing

  4. API places the request in the rabbitMQ queue and returns 202 with a location URL to poll the status.

  5. The celery worker picks up the application and starts processing it. It takes a while to complete.

  6. Meanwhile, the user can poll the status

  7. Once completed, API sends 303, with a URL from another location to download the file.

  8. The user hits the new URL to download the file.

However, our team of architects is not in favor of providing a polling mechanism for the client and asking us to take another approach, it may be a callback URL.
They have something to say: "Busy waiting with sleep to verify if the task is completed, it is not a good programming practice."

I would like to know if there is a different approach that the client can take without having a state survey. The callback is the one I know, but it is not yet in place.

serialization – C # Rest Client Benchmarking

I build a C # Rest Client library / framework. I realized that it seemed to be significantly faster than RestSharp for GET at least. So, I decided to build some benchmarks by comparing it with other clients. I'm a bit new to benchmarking, but I don't want to become obsessed with best practices. Just wanna know

A) Have I introduced bias here?
B) Have I made any obvious mistake?

The four libraries are RestSharp, DalSoft RestClient and my RestClient.Net library. The platform is .NET Core 3.1. I have included a serialization test with the new System.Text.Json (properties that are not case sensitive). I am testing the asynchronous, task-based version of all libraries. These results come from a parallel Windows machine, but will publish OSX results when they are ready. Here I run 6 lots of tests, and I exclude the first batch for each library to eliminate the engine start time bias. The results are the average of the total time. The results are in milliseconds with 250 repetitions.

Here are the results for GET

DalSoft 3527.41

Flurl 1500.3981

RestClient.Net System.Text.Json 2092.2710

RestClient.Net Newtsonsoft 1606.2478

Restharp 9033.2331

Here are the results for POST

DalSoft 850.5417

Flurl 830.1859

RestClient.Net System.Text.Json 1699.9605

RestClient.Net Newtsonsoft 917.9309

Restharp 894.0506

Code reference

(TestClass)
public class PerformanceTests
{
    #region Misc
    (AssemblyInitialize)
    public static void Initialize(TestContext testContext)
    {
        //Load all the assemblies in to the app domain so this loading doesn't skew results
        var flurlClient = new FlurlClient(PeopleUrl);
        var countryCodeClient = new Client(new NewtonsoftSerializationAdapter(), new Uri(PeopleUrl));
        var restSharpClient = new RestSharp.RestClient(PeopleUrl);
        var dalSoftClient = new DalSoft.RestClient.RestClient(PeopleUrl);
        var personJson = JsonConvert.SerializeObject(new Person());
        personJson = System.Text.Json.JsonSerializer.Serialize(new Person());
    }

    private const int Repeats = 250;
    private const string PeopleUrl = "https://localhost:44337/JsonPerson/people";
    private const string Path = "Results.csv";
    private static FileStream stream;

    static PerformanceTests()
    {
        if (File.Exists(Path)) File.Delete(Path);
        stream = new FileStream(Path, FileMode.Append);
        WriteText("Client,Method,First Call,All Calls,Totalrn");
    }

    private static void WriteText(string text)
    {
        var bytes = Encoding.UTF8.GetBytes(text);
        stream.Write(bytes, 0, bytes.Length);
    }

    (AssemblyCleanup())
    public static void AssemblyCleanup() 
    {
        stream.Close();
    }
    #endregion

    #region Flurl
    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestGetFlurl()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var flurlClient = new FlurlClient(PeopleUrl);

        startTime = DateTime.Now;
        var people = await flurlClient.Request().GetJsonAsync>();
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        startTime = DateTime.Now;
        for (var i = 0; i < Repeats; i++)
        {
            people = await flurlClient.Request().GetJsonAsync>();
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"Flurl,GET,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestPostFlurl()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new FlurlClient(PeopleUrl);

        var peopleRequest = new List();
        for (var i = 0; i < 10; i++)
        {
            peopleRequest.Add(new Person { FirstName = "Test" + i });
        }

        startTime = DateTime.Now;
        var people = await ReadPostResponseAsync(countryCodeClient, peopleRequest);
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await ReadPostResponseAsync(countryCodeClient, peopleRequest);
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"Flurl,POST,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    private static async Task> ReadPostResponseAsync(FlurlClient countryCodeClient, List peopleRequest)
    {
        var response = await countryCodeClient.Request().PostJsonAsync(peopleRequest);
        var json = await response.Content.ReadAsStringAsync();
        var people = JsonConvert.DeserializeObject>(json);
        return people;
    }
    #endregion

    #region RestClient.Net
    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestGetRestClientNewtonSoft()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new Client(new NewtonsoftSerializationAdapter(), new Uri(PeopleUrl));

        startTime = DateTime.Now;
        List people = await countryCodeClient.GetAsync>();
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.GetAsync>();
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"RestClient.Net Newtonsoft,GET,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestGetRestClient()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new Client(new Uri(PeopleUrl));

        startTime = DateTime.Now;
        List people = await countryCodeClient.GetAsync>();
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.GetAsync>();
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"RestClient.Net,GET,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestPostRestClient()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new Client(new Uri(PeopleUrl));

        var peopleRequest = new List();
        for (var i = 0; i < 10; i++)
        {
            peopleRequest.Add(new Person { FirstName = "Test" + i });
        }

        startTime = DateTime.Now;
        List people = await countryCodeClient.PostAsync, List>(peopleRequest);
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.PostAsync, List>(peopleRequest);
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"RestClient.Net,POST,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestPostRestClientNewtonsoft()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new Client(new NewtonsoftSerializationAdapter(), new Uri(PeopleUrl));
        countryCodeClient.SetJsonContentTypeHeader();

        var peopleRequest = new List();
        for (var i = 0; i < 10; i++)
        {
            peopleRequest.Add(new Person { FirstName = "Test" + i });
        }

        startTime = DateTime.Now;
        List people = await countryCodeClient.PostAsync, List>(peopleRequest);
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.PostAsync, List>(peopleRequest);
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"RestClient.Net Newtonsoft,POST,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }
    #endregion

    #region RestSharp
    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestGetRestSharp()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new RestSharp.RestClient(PeopleUrl);

        startTime = DateTime.Now;
        var people = await countryCodeClient.ExecuteGetTaskAsync>(new RestRequest { Method = Method.GET });
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.ExecuteGetTaskAsync>(new RestRequest { Method = Method.GET });
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Data.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"RestSharp,GET,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestPostRestSharp()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new RestSharp.RestClient(new Uri(PeopleUrl));

        var peopleRequest = new List();
        for (var i = 0; i < 10; i++)
        {
            peopleRequest.Add(new Person { FirstName = "Test" + i });
        }

        startTime = DateTime.Now;
        var peopleRestRequest = new RestRequest { Method = Method.POST, Body = new RequestBody("application/json", "Person", peopleRequest) };
        var people = await countryCodeClient.ExecutePostTaskAsync>(peopleRestRequest);
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.ExecutePostTaskAsync>(peopleRestRequest);
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Data.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"RestSharp,POST,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }
    #endregion

    #region DALSoft
    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestGetDALSoft()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new DalSoft.RestClient.RestClient(PeopleUrl);

        startTime = DateTime.Now;
        var people = await countryCodeClient.Get>();
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.Get>();
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"DalSoft,GET,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }

    (TestMethod)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    (DataRow)
    public async Task TestPostDALSoft()
    {
        var startTime = DateTime.Now;
        var originalStartTime = DateTime.Now;
        var countryCodeClient = new DalSoft.RestClient.RestClient(PeopleUrl);

        var peopleRequest = new List();
        for (var i = 0; i < 10; i++)
        {
            peopleRequest.Add(new Person { FirstName = "Test" + i });
        }

        startTime = DateTime.Now;
        var people = await countryCodeClient.Post, List>(peopleRequest);
        var timesOne = (DateTime.Now - startTime).TotalMilliseconds;

        for (var i = 0; i < Repeats; i++)
        {
            people = await countryCodeClient.Post, List>(peopleRequest);
            Assert.IsTrue(people != null);
            Assert.IsTrue(people.Count > 0);
        }

        var timesRepeats = (DateTime.Now - startTime).TotalMilliseconds;
        var total = (DateTime.Now - originalStartTime).TotalMilliseconds;

        var message = $"DalSoft,POST,{timesOne},{timesRepeats},{total}rn";
        WriteText(message);
        Console.WriteLine(message);
    }
    #endregion
}

System.Text.Json looks promising in upper and lower case mode. It seems to be faster than Newtonsoft without distinction between upper and lower case. But, we still have to investigate whether it can be faster or not in other situations.

remote – Rest API: sending an image linked to a post published remotely.

I am creating an application that will allow the user to manage / send publications to the WP sites that they will manage, remotely, from the same web application, without accessing any of the WP sites, obviously …
I have achieved the above, using cURL and the WP Rest API, but I am stuck with adding / including a function image or any type of media within the publication, trying to imitate the way it is done within WP, using tinyMCE as a text editor.
Any ideas on how to proceed to ensure fluency?
I have read that one has to do a double operation: first load the desired image and then add its ID through a PUT request in the post description / feature_post field, if it is a characteristic image …
Any other way to proceed since the latter is not very easy for the end user to use?
Thank you very much I am building an application that will allow the user to manage / send publications to the WP sites that he will administer, remotely, from the same web application, without accessing any of the WP sites, obviously …
I have achieved the above, using cURL and the WP Rest API, but I am stuck with adding / including a function image or any type of media within the publication, trying to imitate the way it is done within WP, using tinyMCE as a text editor.
Any ideas on how to proceed to ensure fluency?
I have read that one has to do a double operation: first load the desired image and then add its ID through a PUT request in the post description / feature_post field, if it is a characteristic image …
Any other way to proceed since the latter is not very easy for the end user to use?
Thank you

Sleep wake: SSH remote access to the MacBook Pro at rest only works when the application is running & # 39; Find my Mac & # 39 ;. Can I make this persist?

As expected, I cannot enter SSH to my MacBook when I left it with the cover closed / inactive, but if I use my iPhone to access & # 39; Find my Mac & # 39 ;, the MacBook is activated and then I can enter SSH.

However, when my iPhone falls asleep / I leave & # 39; Find my Mac & # 39 ;, the SSH connection hangs.

Is it possible to use & # 39; Find my Mac & # 39; to activate my MacBook for SSH and then this connection persists after closing & # 39; Find my Mac & # 39 ;?

The specific group site cannot be accessed using the SharePoint REST APIs

Objective: I want to create a folder on my custom group site in SharePoint using the REST APIs.

Steps I have followed:


  

  • After obtaining the access token to access those REST APIs, I have also created an application in "Application Registration" in Azure Portal.
  • When creating them, I provided the following API permission for this application.

enter the description of the image here

  • After doing so, I was able to obtain the Bearer access token.

enter the description of the image here

  • Then I could create a folder, attach a file to a new application in SharePoint using the REST APIs. But All that happened in the communication site.

My requirement is to create a folder within a custom site (group site).
For that I created a custom site using the web interface.
Called Name: TeamSite_ForB

Below is the URL of the REST endpoint I am trying to access:

https://***.sharepoint.com/sites/TeamSite_ForB/_api/web/folders

I am using postman in this case.

Then, in the authorization, I configured the bearer token. In addition, I have also configured the following request headers:

Content type: application / json; odata = verbose

Accept: application / json; odata = verbose

X-RequestDigest: random string provided by sharepoint

Then, in the request body, I configured the following JSON:

{ 
    "__metadata":{ 
        "type":"SP.Folder"
    },
    "ServerRelativeUrl":"/sites/TeamSite_ForB/Shared Documents/testFolder"
}

But when I send the request, I receive the following error response with 403 prohibited.

{
    "error": {
        "code": "-2147024891, System.UnauthorizedAccessException",
        "message": {
            "lang": "en-US",
            "value": "Access denied. You do not have permission to perform this action or access this resource."
        }
    }
}

Important:
If I put the endpoint of the URL as shown below and the body of the request as shown below, I get 201 response codes and folders created within the "communication site".

https://***.sharepoint.com/_api/web/folders

Application body:

{ 
    "__metadata":{ 
        "type":"SP.Folder"
    },
    "ServerRelativeUrl":"/Shared Documents/testFolder"
}

Therefore, I simply do not want to create a folder within the communication site, rather I want to create within the custom team site.

I searched Google for my articles and reviewed the documentation of the shared point and could not find any solution for this error.

Any help would be highly appreciated.

rest api – Magento 2.2.2 Plugin how to add a custom field in the request API

I have created a complement to listen to api POST /V1/order/:orderId/refund

and I would like to receive a custom field. I have added a field to try as: name:('test')

Body E.G:

{
    "items": (
        {
            "extension_attributes": {},
            "order_item_id": 7,
            "qty": 1
        }
    ),
    "isOnline": false,
    "notify": true,
    "appendComment": true,
    "name": (
      { 
          "test": "ok" 
      }
    ), //THIS IS MY CUSTOM FIELD
    "comment": {
        "extension_attributes": {},
        "comment": "refund has been created",
        "is_visible_on_front": 0
    },
    "arguments": {
        "shipping_amount": 0,
        "adjustment_positive": 0,
        "adjustment_negative": 0,
        "extension_attributes": {
            "return_to_stock_items": ()
        }
    }
}

beforeExecute Method:

...
    /**
     * Create refund for invoice
     *
     * @param int $invoiceId
     * @param MagentoSalesApiDataCreditmemoItemCreationInterface() $items
     * @param bool|null $isOnline
     * @param bool|null $notify
     * @param bool|null $appendComment
     * @param MagentoSalesApiDataCreditmemoCommentCreationInterface|null $comment
     * @param MagentoSalesApiDataCreditmemoCreationArgumentsInterface|null $arguments
     * @param mixed $name
     * @return int
     * @since 100.1.3
     */

    public function beforeExecute (
        MagentoSalesModelRefundOrder $subject,
        $orderId,
        array $items = (),
        $notify = false,
        $appendComment = false,
        MagentoSalesApiDataCreditmemoCommentCreationInterface $comment = null,
        MagentoSalesApiDataCreditmemoCreationArgumentsInterface $arguments = null,
        array $name = ()
    ) {
        print_r($name);die;
      }
...

My custom field name it is a matrix similar to items: but I'm getting an empty array of Response:
s

Anyone any help appreciated!

magento2.3 – Magento 2: How to display data from the rest of the external API using the custom module in Magento2

I want to create a custom module in which, I want to get some external data using REST API ( https://reqres.in/api/unknown) and display them on the home page.

I have never worked with API in Magento 2. Can anyone suggest a link or method to start?

Generate a password protected file link using the REST API?

Is it possible to generate a password protected link for a file in SharePoint through the REST API?

xamarin – Api Rest with .Net Core

Friends I have a question I have an Api web project in .net core, and another solution in an xamarin forms project my question is to be able to consume it from xamarin forms is it necessary to publish it either in IIS? since I am trying to consume it but I get an error that I can not connect to the service as it does not find the port, but from another project that I have with vue js if I can consume it what should I do in xamarin forms to be able to consume it?

In advance if anyone could help me I would appreciate it …