https://github.com/timoliver/cloudkit-php
For server-to-server comms from PHP to CloudKit.
https://github.com/timoliver/cloudkit-php
Last synced: 4 months ago
JSON representation
For server-to-server comms from PHP to CloudKit.
- Host: GitHub
- URL: https://github.com/timoliver/cloudkit-php
- Owner: TimOliver
- License: mit
- Created: 2021-10-14T14:20:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-03T13:34:13.000Z (over 1 year ago)
- Last Synced: 2025-01-26T06:25:39.420Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CloudKit-PHP
Today I found this fantastic [gist](https://gist.github.com/Mauricevb/87c144cec514c5ce73bd) by [Mauricevb](https://gist.github.com/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](https://developer.apple.com/library/ios/documentation/CloudKitJS/Reference/CloudKitJavaScriptReference/index.html#//apple_ref/doc/uid/TP40015359)
[Accessing CloudKit Using a Server-to-Server Key](https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/SettingUpWebServices/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW6)
[CloudKit Web Services Reference](https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40015240-CH1-SW1)
## Example
```php
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";
}
?>
```