• Resolved tkinsella

    (@tkinsella)


    Hello!
    I am trying to learn the wordpress API and would like to do some simple things with it, such as set a site timezone.

    I am using BASH for this and cURL.

    Using:
    SET_TIMEZONE=curl -X PUT -i https://$SITE_URL/wp-json/wp/v2/settings?timezone=”Los Angeles”

    I am able to retrieve the site settings, but can’t seem to get it to update. Any assistance would be appreicated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous User 14808221

    (@anonymized-14808221)

    Cant you just use the Options API?

    Something like this would do the trick:

    
    $offset = -5;
    
    update_option( 'gmt_offset', $offset );
    update_option( 'timezone_string', 'America/New_York' );
    

    If you mean to use the REST API, I have to pass on this one, as not an expert with it.
    I believe however there is no endpoint for the options in the REST API. But again I am no expert at all when it comes to REST.

    • This reply was modified 5 years, 1 month ago by Anonymous User 14808221.
    Moderator bcworkz

    (@bcworkz)

    You need to use proper authentication. Requirements vary by method, but generally speaking, some sort of security token must accompany every request.
    https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/

    If you’re not sure which to use, I recommend application passwords:

    Application Passwords: Integration Guide

    Thread Starter tkinsella

    (@tkinsella)

    I was able to resolve this. Turns out I needed to specify the PHP timezone:
    /wp-json/wp/v2/settings?timezone=America/Los_Angeles

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

The topic ‘API Assistance – Change Settings’ is closed to new replies.