Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/florindumitru/stackmobphp

PHP class to connect to StackMob API
https://github.com/florindumitru/stackmobphp

Last synced: about 18 hours ago
JSON representation

PHP class to connect to StackMob API

Awesome Lists containing this project

README

        

This is a simple PHP class to connect to StackMob APIs

How to use:

1) Configure variables

please change

YOUR-CONSUMER-KEY
YOUR-CONSUMER-SECRET
YOURAPP

with values you can find here: https://www.stackmob.com/platform/account/apps/reset

define('CONSUMER_KEY', 'YOUR-CONSUMER-KEY');
define('CONSUMER_SECRET', 'YOUR-CONSUMER-SECRET');

define('API_URL_GET', 'http://api.mob1.stackmob.com/api/0/YOURAPP');
define('API_URL_PUT', 'http://api.mob1.stackmob.com');
define('API_URL_POST', 'http://api.mob1.stackmob.com/api/0/YOURAPP');
define('API_URL_DELETE', 'http://api.mob1.stackmob.com/api/0/YOURAPP');

2) Test CRUD

we suppose you already created a dumb schema ("dumb") in your stackmob interface with dumb_id and name.

put('dumb'); //all dumb list
$response = $SMConnector->put('dumb','dumb_unique_id'); //ony dumb_unique_id object

POST:

$obj = array();
$obj[dumb_id]='dumb_unique_id';
$obj[name]='awesome_dumb_name';

$response = $SMConnector->post('dumb',$obj);

PUT:

$obj = array();
$obj[dumb_id]='dumb_unique_id';
$obj[name]='awesome_dumb_name';

$response = $SMConnector->put('dumb',$obj);

DELETE:

$response = $SMConnector->delete('dumb','dumb_object_to_delete'); //to delete the object dumb_object_to_delete

enjoy!