Download the PHP package shadiakiki1986/wp-api without Composer

On this page you can find all versions of the php package shadiakiki1986/wp-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-api

This is a fork, published at packagist under shadiakiki1986/wp-api

Install with composer require shadiakiki1986/wp-api

The client id field and client secret field need to be obtained after creating a new Application in Wordpress. Using wordpress.com, it can be done with the applications manager as documented on wordpress's oauth2 page. Note that this package uses grant_type => password documented on the oauth2 page (i.e. to use username and password directly)

WordPress API

This package allows Laravel users to interact with the WordPress API. I personally use this as a way to abstract the WordPress backend from the frontend of the website.

Usage

Usage is simple as you can hope...

<?php

use Neo\WpApi\WpApi;
use Neo\WpApi\Service\GuzzleService;

// Get the instance of the WP Api
$wp = new WpApi(new GuzzleService);

// Set the configuration
$config = array(
    'client_id'     => '',
    'client_secret' => '',
    'username'      => '',
    'password'      => '',
    'site_id'       => '',
);

// Connect to the API
$wp = $wp->setConfig($config)->connect();

// Make your API calls

$posts = $wp->postsByPage(1, 10);

$post = $wp->postById(400);

$post_likes = $wp->api('GET', 'sites/$site_id/posts/$post_id/likes');

Laravel Users

Laravel users can just include the service provider Neo\WpApi\WpApiServiceProvider in their app configuration file.

You can now run artisan config::publish to publish the configuration file and customise.

<?php

$wp = App::make('wp-api')->connect();

// Make your api calls...

$posts = $wp->postsByPage(1);

Advice

This WordPress API uses the grant "password" type which is meant for testing purposes, though I would not mind using it on a real WordPress site since it allows me completely abstract my wordpress site as a back end.

Note that its recommended you use the 2-step authentication and create an Application password in your Wordpress.com dashboard. Using your actual Wordpress password is not recommended.

Enjoy.


All versions of wp-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 4.2.*
guzzle/guzzle Version 3.9.*@dev
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shadiakiki1986/wp-api contains the following files

Loading the files please wait ....