Category: RESTFul

Using OAuth2 to make authenticated calls to WP REST API

clueless

WP REST API is a cool solution for the developers who want to interact with their WordPress blogs programmatically. It’s handy and pretty useful. However, the documentation lacks some working examples which makes a lot of people confused. I’ve started to document some working examples at http://wpapi.xyz. The list is small, but it’s growing.

Anyway, I’ve made a small video tutorial last night to demonstrate how to authenticated yourself using OAuth2 and make some authenticated calls to your WP REST API endpoint. There are hundreds of confused users floating out there looking for a solution, and I hope this video will fix it. Let me know if you find it useful

Enjoy!

OpenShift PHP Rest Client Library

I have been working whole day today on writing this rest client library for php developers to communicate with Openshift REST api. OpenShift is a fantastic Polyglot PaaS (Platform-as-a-Service) brought to you by RedHat. To perform various operations with your openshift account you need to use their command line tool “rhc” (a gem, requires ruby). Their web based admin panel is good for starters, but you need to master the rhc for other essential tasks, for example to add a domain alias or to start/stop/restart your application.

This OpenShift-PHP-Client library can directly invoke their rest api and makes it easier for you if you are a PHP developer. This application is in a good stage at this moment and you can do everything with domains, applications and cartridges.

How to use this library? First checkout the library from it’s github repo located at https://github.com/hasinhayder/openshift-php-client. Then see the source code of the example.php. The example contains the bare minimum, you can actually do a lot of other things with these Domain, Application and Cartridge object. To understand the scope, feel free to check their source code as well 🙂

[sourcecode language=”php”]
include_once("lib/openshift.php");
$username = "YourUsername";
$password = "YourPassword";
$openshift = new OpenShift($username,$password);
// Create a New Domain
$data = $openshift->getDomainManager()->createDomain("osphp");

// List Domains
$data = $openshift->getDomainManager()->getDomains();

// Rename the Domain
$data = $openshift->getDomainManager()->getDomain("osphp")->updateName("moonlander") ;

// Create a Zend 5.6 App Container
$data = $openshift->getDomainManager()->getDomain("osphp")->createApplication("restclient","zend-5.6");

// Get all Applications
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplications();

// Get Application Details
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->getDetails();

// Stop an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->stop();

// Start an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->start();

// Restart an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->restart();

// Reload an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->reload();

// Add an Alias
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->addAlias("mydomain.com");

// Remove an Alias
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->removeAlias("mydomain.com");

Add a MySQL Cartridge
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->addCartridge("mysql-5.1");

// Delete a MySQL Cartridge
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->getCartridge("mysql-5.1")->delete();

// There are many other methods supported by applications, domains and the cartridges. For details, check their source code.
[/sourcecode]

OpenShift PHP Client library is released under MIT License. I am working continuously to add more features to it.

Enjoy!

Shameless Plug

We develop beautiful Admin Panel templates for the web application developers. Our recent product is “Bolt” which is responsive and built on top of Twitter’s bootstrap. Give it a try and let us know how do you like it.

Bolt Responsive Admin Panel Template for Developers
Bolt Responsive Admin Panel Template for Developers

RackSpace Cloud Server Client Library for PHP

We, the developers at Leevio are currently developing an open source group collaboration application. We are using RackSpace Cloud servers since the very beginning of the development and we will also deploy in on rack space cloud.

As a part of our study we’d found that RackSpace provides excellent API to manage your cloud services. Unfortunately there are no language binding library released yet (for Cloud Server). But they’ve mentioned that they are developing one for python.

So we have spend our time for last two days and developed a PHP client library to use RackSpace cloud server API from inside a PHP application.

This client library is released under New BSD license. And is available to download/svn-checkout from it’s project page at http://code.google.com/p/phprackcloud/

There is plenty of documentation and example included. The code is mostly self explanatory. Please dont forget to check the Wiki page to get some idea on how to use this library and how far you can go. We have covered all available methods by RackSpace cloud server in our client library.

Happy clouding.

Project Page and Download: http://code.google.com/p/phprackcloud