The official PHP client for Cosmic JS. This module will help you easily add dynamic content to your website or application.
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md Update README.md Jan 22, 2016
cosmicjs.php
curl.php blast off Jul 23, 2015
example.php Update example.php Dec 28, 2015

README.md

Cosmic JS Logo

Getting started

Go to https://cosmicjs.com, create an account and setup a bucket.

Install

git clone https://github.com/cosmicjs/cosmicjs-php

Usage

<?php
/* !!!! CONFIGURE !!!!
==================================== */
$config = new stdClass();
$config->bucket_slug = "driver-example"; // bucket slug
$config->read_key = ""; // leave empty if not required
$config->write_key = ""; // leave empty if not required
include("cosmicjs.php");

/* Add
================================= */
$object_string = '{
  "type_slug": "pages",
  "title": "Test Title",
  "content": "here is some test content",
  "write_key": "' . $config->write_key . '"
}';
$object = $cosmicjs->addObject($object_string);

/* Edit
================================= */
$object_string = '{
  "slug": "test-title",
  "title": "New Title",
  "content": "here is some NEW test content",
  "write_key": "' . $config->write_key . '"
}';
$object = $cosmicjs->editObject($object_string);

/* Delete
================================= */
$object_string = '{
  "slug": "test-title",
  "write_key": "' . $config->write_key . '"
}';
$object = $cosmicjs->deleteObject($object_string);

/* Get Objects
================================= */
$objects = $cosmicjs->getObjects();

/* Get Media
================================= */
$media = $cosmicjs->getMedia();
?>