Giter Club home page Giter Club logo

client-cli's Introduction

WP REST API v2.0 (formerly known as WP-API)

Access your WordPress site's data through an easy-to-use HTTP REST API.

Development is no longer taking place in this repository.

  • For support requests, use the WordPress forums.
  • For bugs and patches, use WordPress core Trac. Be sure to include full details and reproduction steps about the issue you are experiencing, and ideally a patch with unit tests.

The "develop" branch is version 2 which represents the last "beta" versions of the plugin. Read the documentation to introduce yourself to endpoints, internal patterns, and implementation details.

The "master" branch represents the legacy version of the REST API.

About

WordPress is moving towards becoming a fully-fledged application framework, and we need new APIs. This project was born to create an easy-to-use, easy-to-understand and well-tested framework for creating these APIs, plus creating APIs for core.

This plugin provides an easy to use REST API, available via HTTP. Grab your site's data in simple JSON format, including users, posts, taxonomies and more. Retrieving or updating data is as simple as sending a HTTP request.

Want to get your site's posts? Simply send a GET request to /wp-json/wp/v2/posts. Update user with ID 4? Send a PUT request to /wp-json/wp/v2/users/4. Get the page with slug "about-me"? GET /wp-json/wp/v2/pages?slug=about-me. Get all posts with the search term "awesome"? GET /wp-json/wp/v2/posts?search=awesome. It's that easy.

The WordPress REST API exposes a simple yet easy interface to WP Query, the posts API, post meta API, users API, revisions API and many more. Chances are, if you can do it with WordPress, the API will let you do it.

The REST API also includes an easy-to-use JavaScript API based on Backbone models, allowing plugin and theme developers to get up and running without needing to know anything about the details of getting connected.

Check out our documentation for information on what's available in the API and how to use it. We've also got documentation on extending the API with extra data for plugin and theme developers!

The API code in this plugin is currently integrated into core WordPress starting in 4.7.

Development is no longer taking place in this repository.

  • For support requests, use the WordPress forums.
  • For bugs and patches, use WordPress core Trac. Be sure to include full details and reproduction steps about the issue you are experiencing, and ideally a patch with unit tests.

Quick Setup

Want to test out the WP REST API? The easiest way is just to install a recent version of WordPress (4.7 or later).

Testing

You can also set up a development environment to work on the API code.

See the instructions for running the WordPress PHPUnit test suite to get started.

Issue Tracking

All tickets for the project are being tracked on WordPress core Trac.

Some previous issues can be found on the issue tracker for this repository; however, now that development of the API has moved to core Trac, new issues should not be filed here.

Contributing

Want to get involved? Check out Contributing.md for details on submitting fixes and new features.

Security

We take the security of the API extremely seriously. If you think you've found a security issue with the API (whether information disclosure, privilege escalation, or another issue), we'd appreciate responsible disclosure as soon as possible.

To report a security issue, you can either email security[at]wordpress.org, or file an issue on HackerOne. We will attempt to give an initial response to security issues within 48 hours at most, however keep in mind that the team is distributed across various timezones, and delays may occur as we discuss internally.

(Please note: For testing, you should install a copy of the project and WordPress on your own server. Do not test on servers you do not own.)

License

GPLv2+

client-cli's People

Contributors

danielbachhuber avatar rmccue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

client-cli's Issues

Beware of logic that outputs stuff during 'shutdown' filter processing

I have a trace plugin that hooks into the 'shutdown' action. When the request is NOT an AJAX request, it's programmed to output some information back to the requester.

Even though I've added some code to stop it doing this when WP_JSON is defined I haven't yet fixed the problem. I've only caught some of the instances where the logic should not be run.

The end result is that my WP-CLI cache file for api/oauth1- has been 'infected' with this output.
The "secret" field in OAuthToken starts off OK, but the output from the trace routine has been appended to it. So instead of being 48 bytes it's 324 bytes.
AND this causes a problem for the next request since it creates the wrong value for the $key used to create the oauth_signature.

Can anyone advise one or more fixes for this problem that will
a) work for me
b) work for anyone else who's attempting something similar.

Options include:

  • Knowing what to check for during 'shutdown' processing.
  • Sanitizing the fields before serializing them into the cache

Sorry, you are not allowed to create new posts

Has anybody successfully created posts from an Ionic app?
I have an ionic app successfully negotiating the first leg of the oauth 1.0a process, but when I try to actually create a post I get an rest_cannot_create error.

Response from service:

Error creating post! {"data":{"code":"rest_cannot_create","message":"Sorry, you are not allowed to create new posts.","data":{"status":401}},"status":401,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"url":"http://service.com/wp-json/wp/v2/posts","data":{"title":"Foo title","content":"Foo content","status":"publish"},"headers":{"Accept":"application/json, text/plain, /","Authorization":"OAuth oauth_consumer_key="1fuYx4bx8EOM", oauth_nonce="rGAQfWZwq4cecXlzMdQBiG7cR673I0Lx", oauth_timestamp="1459875496", oauth_signature_method="HMAC-SHA1", oauth_token="bIDQOcdep8jf0jLg6cF1wpHX", oauth_version="1.0", oauth_signature="EPj%2FRCgf%2BlKXnFB9F5q0Vn7Njg8%3D"","Content-Type":"application/json;charset=utf-8"}},"statusText":"Unauthorized"}

Oauth keys doesn't pass validation

// Excuse my beginner's English
Hi guys!

I have installed all prerequisity packages from the WP-API/client-cli/readme.md (on the server and on the client).
And i have completed steps 0, 1.
But on the step 2 i faced a problem.

wp --require=./wp-content/plugins/client-cli/client.php api oauth1 connect $MY_DOMAIN --key=uSHRj14xsc8S --secret=RiA8ElltDntSwOGdBNrgLro6brfqHTW5WKCFc2yjPTyFk7oK
Error: 401 Unauthorized

Have any ideas?
Thanks!

Error: Class `WPAPI` not found...

I am getting an error when running this command:

wp --require=client.php api oauth1 connect http://example.com --key=4ugulKVfFNka --secret=ozGESz8v4FNdmpoCfPw9gNqk9qbc29IAMujaaSPxapAduiml

PHP Fatal error: Class 'WPAPI' not found in /home/dschiera/wp-cli/client-cli/lib/commands/base.php on line 29

I am using a different url of course.
The Wordpress installation I'm posting to has JSON REST API and OAuth Server Plugins installed.
I was able to authenticate.
I used composer install, and composer update.
I'm running PHP 5.5.10.

Generate access token

Currently, we get a request token and get the user to authorise it, but don't convert this to an access token.

Image link is broken

"Open this up in your browser, log in if needed, and authorize the account. You'll then see an authorization code: [Authorization code] <- Not Found"

undefined index: oauth_token in lib/commands/oauth1.php line 69 and 80

I'm following the docs. Using VVV, latest oauth plugin and client-cli

I generate the keys:

vagrant@vvv:/srv/www/server/wp-content/plugins/client-cli$ wp oauth1 add
ID: 3403
Key: A7qjbeSycs4F
Secret: x4VUp0aE9q1jz0S06VcKyjS8ZZ0daLshF8Y4SNt4eQKFYg0b

Then I run the command on the client:

vagrant@vvv:/srv/www/client/wp-content/plugins/client-cli$ wp --require=client.php api oauth1 connect http://bbboltserver.one.localhost/ --key=A7qjbeSycs4F --secret=x4VUp0aE9q1jz0S06VcKyjS8ZZ0daLshF8Y4SNt4eQKFYg0b
PHP Notice:  Undefined index: oauth_token in /srv/www/client/wp-content/plugins/client-cli/lib/commands/oauth1.php on line 69
PHP Notice:  Undefined index: oauth_token in /srv/www/client/wp-content/plugins/client-cli/lib/commands/oauth1.php on line 80
Open in your browser: http://server.localhost/oauth1/authorize?oauth_token=
Enter the verification code:
Error: 401 Unauthorized

The script waits for me to enter the verification code. What's that?

composer install fails

salty-wordpress โžœ  wp-api-cli-client  composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package requestsphp/oauth1 could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Can't OAuth1 Connect

I am running this on my local VVV install:

First I ran the following command:

wp --url=http://local.vistage.dev/southwest oauth1 add

Result:

ID: 2516
Key: SXh2rc4SaIIb
Secret: nDtR5t0qgzSLU472SDN6Js8LEU0WEINkkN7BLfhyxVIJGQdu

Then I ran the following:

wp --require=client.php api oauth1 connect http://local.vistage.dev/southwest --key=SXh2rc4SaIIb --secret=nDtR5t0qgzSLU472SDN6Js8LEU0WEINkkN7BLfhyxVIJGQdu

Result:

Error: 401 Unauthorized

I can't use with this project

Hi !
When I just try to link the client with my server, this is what I get:

$ wp --require=client.php api oauth1 connect "http://wordpress-local/" --key=L3CnXXXXXDU6 --secret=N7tJrvUbEZh0TVriMuP4LkXXXXXXXXXXYVWdDPkgWSgj4
PHP Notice:  Undefined index: url in /home/yakir/Git/client-cli/lib/locator.php on line 34
PHP Stack trace:
PHP   1. {main}() /usr/bin/wp:0
PHP   2. include() /usr/bin/wp:4
PHP   3. include() phar:///usr/bin/wp/php/boot-phar.php:5
PHP   4. WP_CLI\Runner->before_wp_load() phar:///usr/bin/wp/php/wp-cli.php:20
PHP   5. WP_CLI\Runner->do_early_invoke() phar:///usr/bin/wp/php/WP_CLI/Runner.php:599
PHP   6. WP_CLI\Runner->_run_command() phar:///usr/bin/wp/php/WP_CLI/Runner.php:52
PHP   7. WP_CLI\Runner->run_command() phar:///usr/bin/wp/php/WP_CLI/Runner.php:311
PHP   8. WP_CLI\Dispatcher\Subcommand->invoke() phar:///usr/bin/wp/php/WP_CLI/Runner.php:304
PHP   9. call_user_func:{phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:293}() phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:293
PHP  10. WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}() phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:293
PHP  11. call_user_func:{phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:52}() phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:52
PHP  12. WP_JSON\CLI\Commands\OAuth1->connect() phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:52
PHP  13. WP_JSON\CLI\Locator->locate() /home/yakir/Git/client-cli/lib/commands/oauth1.php:51
Error: Could not locate API; are you sure it's enabled?

When I try to send var_dump( $real_links ); in lib/locator.php:90 (before the return), This is the output:

array(1) {
  [0] =>
  array(2) {
    '<http://wordpress-local/?json_route' =>
    string(2) "/>"
    'rel' =>
    string(32) "https://github.com/WP-API/WP-API"
  }
}

What you think the problem?
Thanks!

cURL error 77: error setting certificate verify locations

Hi,

when running php wp-cli.phar --require=client.php api oauth1 connect https://example.com --key=key --secret=secret (obfuscated), I get the following error:

Error: cURL error 77: error setting certificate verify locations:
  CAfile: phar:///var/www/html/client-cli/wp-cli.phar/vendor/rmccue/requests/library/Requests/Transport/cacert.pem
  CApath: none

Any ideas what the problem might be?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.