• Hi,

    I am creating a PHP script in another server to access my WP site,
    But I don’t use WordPress on that server,
    What is the best way to connect to WP REST API in this situation?
    is there any class in WordPress to include in my PHP script to connect to my site?
    or any good class for such things?
    a PHP client REST API

    Appreciate for any help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Thread Starter ParsMizban

    (@parsmizban)

    @sterndata
    Hi, I am trying to find a PHP client class !
    Which there isn’t any mentioned here:
    https://developer.wordpress.org/rest-api/using-the-rest-api/client-libraries/
    any thing?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I can google it or you can. 🙂 I think it’s best that you do it.

    Something like “rest API wordpress php examples”

    Thread Starter ParsMizban

    (@parsmizban)

    @sterndata
    Most of them are related to WordPress based applications, Not independent PHP applications
    I tested 2-3 other libraries as PHP client but none of them work properly

    Moderator bcworkz

    (@bcworkz)

    You can use any HTTP transport mechanism. Even file_get_contents() will get API data. I personally would use cURL, but it’s not available on all servers.

    @bcworkz
    I wrote the code using cURL, But I have problem with uploading files and also authentication, Could you please give me a proper sample for that?
    is it need to install a plugin for authentication or it can be done without any plugin?
    I worked with XML-RPC before and it works without any plugin for authentication
    Also I checked this library:
    https://github.com/WP-API/client-php
    It seems that it written by API team but there isn’t any documentation about how to use and methods

    Moderator bcworkz

    (@bcworkz)

    Yeah, REST and RPC are entirely unrelated. You can get some information from the API without authentication, but posting data certainly requires authentication. The default cookie authentication will not work for remote server access, so yes, you must use an authentication plugin.

    I’m sorry, I don’t have any functional examples that fit your situation. In particular where file uploads are involved. Maybe I’m missing something, but I’m not aware of any upload functionality in the default API. I suppose the API could be extended to allow for uploads, but I’m not sure how that would work. I barely know how conventional uploads work from a browser.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘access WP REST API from remote site’ is closed to new replies.