For server-to-server comms from PHP to CloudKit.

Overview

CloudKit-PHP

Today I found this fantastic gist by Mauricevb that demonstrates how to communicate with CloudKit from PHP. I already had a previous project that used a backend similar to CloudKit so by replacing the web request code with his I've created this PHP library for CloudKit. It's very much a work in progress and it would be great if anyone could contribute to fill in the missing methods.

Status

Fetching, querying and saving records is partially working.

Development Resources

CloudKit JS Reference

Accessing CloudKit Using a Server-to-Server Key

CloudKit Web Services Reference

Example

<?php
require dirname(__FILE__).'/autoload.php';
use CloudKit\Container;
use CloudKit\Record;
use CloudKit\Query;
use CloudKit\Location;

$container = new Container('iCloud.com.container', // containerID
  '9bbf2b399e9cd74x372bb4ec11cb5x1b7f0d73db16a24x08a018', // keyID, see Accessing CloudKit link above 
  'eckey.pem', // private key file, again see accessing CloudKit.
  'development'); // environment

$query = new Query("Venue");
//$query->filter('name', 'Java Earth');
$query->filter('name', '=', 'Java Earth');
//$query->filterIn('name', ['Java Earth']);
$response = $container->getPublicCloudDatabase()->performQuery($query, [ 'resultsLimit' => 1 ]);

if($response->hasErrors()) {
    echo $response->getErrors()[0]->getReason();
    return;
}

$records = $response->getRecords();


$record = NULL;
if(count($records) > 0) {
    $record = $records[0];
}else{
    $record = new Record('Venue');
}

$record->setField('name', 'Java Earth');
$record->setField('formattedAddress', '4978 Cass St, San Diego, CA 92109, United States');
$record->setField('location', new Location(32.805509, -117.254510));
$response2 = $container->getPublicCloudDatabase()->saveRecords([$record]);
if($response2->hasErrors()) {
    var_dump($response2->getErrors()[0]);
}else{
    echo "Success\n";
}

?>
You might also like...
Run PHP scripts on the fly at runtime on a PocketMine-MP server (useful for debugging)

Scripter Run PHP scripts on the fly at runtime on a PocketMine-MP server. This is useful for runtime debugging, when you don't want to restart the ser

Minimalistic bookmark manager for your own server written in PHP. Bookmarks are stored in a sqlite database.

b - Bookmark manager b is a minimalistic bookmark manager for your own server. Written in PHP. Bookmarks are stored in a sqlite database. Features: fi

An open-source Minecraft: Java Edition server implementation, written in PHP.
An open-source Minecraft: Java Edition server implementation, written in PHP.

PHPCraft An open-source Minecraft: Java Edition server implementation, written in PHP. What is PHPCraft? PHPCraft is an open-source Minecraft: Java Ed

It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help

[Magento 1 Extension] It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help (without any php code).

Auto RELOAD dan
Auto RELOAD dan "live server" untuk PHP file

PHP BrowserSync Auto Reload your Browser and PHP file ini adalah auto reload php file atau browser, jika ada perubahan di file php atau di file js dan

A php package to get the server information.

A php package to get you the server information Install Via Composer $ composer require ameetroy/server Usage use BubbleGum\Sweety; $getTotalSpace =

Sample application to bookmark links, where interface build with Angular.js + Twitter Bootstrap and server powered by PHP with Slim Framework

RESTful Bookmarks PHP Slim TODO: review and update FrontEnd Sample application to bookmark links, where interface build with Angular.js + Twitter Boot

AppGallery IAP is a PHP library to handle AppGallery purchase verification and Server Notifications

AppGallery IAP About AppGallery IAP is a PHP library to handle AppGallery purchase verification and Server Notifications. This package simplifies deve

Grpc go-server php-client

Grpc go-server php-client

Owner
Tim Oliver
Gamer. Developer. Geek. Senior Software Engineer at @Drivemode (prev. @Realm). Lover of writing iOS code and singer of bad karaoke. 日本語もオッケ〜
Tim Oliver
Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)

COPS COPS stands for Calibre OPDS (and HTML) Php Server. See : COPS's home for more details. Don't forget to check the Wiki. Why ? In my opinion Calib

Sébastien Lucas 1.3k Jan 1, 2023
This project processes a small database with php all on a web server. This project uses XAMPP to run the web server and the database.

PHP-introduction This project processes a small database with php all on a web server. This project uses XAMPP to run the web server and the database.

Tyler Jacques 1 Jan 6, 2022
A plugin that allows you to hear the sound "Welcome to the server!" when you join the server by NhanAZ for PocketMine-MP

General A plugin that allows you to hear the sound "Welcome to the server!" when you join the server by NhanAZ for PocketMine-MP Contacts You can cont

NhanAZ's PocketMine-MP Plugins 10 Sep 27, 2022
EXT:server-timing adds Server-Timing Header with usefull information

EXT:server_timing - see your performance installation composer require kanti/server-timing at the moment there is nothing to configure Server timings

Matthias Vogel 4 Oct 26, 2022
A Simplistic Plugin to Implement Server Claims to your Minecraft: Bedrock Server.

Claims This plugin allows administrators to create, edit, list, and teleport to land claims on a PocketMine server. These claims have a variety of cus

Santana 5 Jun 10, 2023
A multithreaded application server for PHP, written in PHP.

appserver.io, a PHP application server This is the main repository for the appserver.io project. What is appserver.io appserver.io is a multithreaded

appserver.io 951 Dec 25, 2022
A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

Felix Becker 1.1k Jan 4, 2023
A server software for Minecraft: Bedrock Edition in PHP

A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP Getting started Documentation Installation instructio

PMMP 3k Dec 31, 2022
Simple game server with php without socket programming. Uses the Api request post(json).

QMA server Simple game server with php without socket programming. Uses the Api request post(json). What does this code do? Register the user as a gue

reza malekpour 3 Sep 4, 2021
⚙️ Web3 PHP CLI is a blazing fast blockchain server for local development.

Web3 PHP CLI is a blazing fast blockchain server for local development. This project is a work-in-progress. Code and documentation are currently under

Web3 PHP 139 Jan 6, 2023