castle / castle-php Goto Github PK
View Code? Open in Web Editor NEWPHP library for Castle
Home Page: https://castle.io
License: MIT License
PHP library for Castle
Home Page: https://castle.io
License: MIT License
You could use an autoloader on lib/Castle.php this is very easy todo.
lib/Castle/autoloader.php
<?php
/**
* Get all files from the lib directory and require them.
*/
function getFiles()
{
$files = array_diff(scandir(dirname(__FILE__)), array('..', '.'));
foreach($files as $file)
{
require($file);
}
}
spl_autload_register('getFiles');
lib/Castle/Castle.php
// Everything above requires remain the same
require(dirname(__FILE__) . '/autoloader.php');
// All other requires can be removed.
This should greatly reduce the amount of effort needed to maintain this lib.
Another valid way of doing this (even easier) would be to use the following code in place of all the requires
require(dirname(dirname(__FILE__)) . "/vendor/autoload.php");
Thus using composer.
Our new APIs allow Admins to directly approve and report a device with a device token, not need to collect the request context. However, these APIs, included the Device fetching API, are not available via our SDK.
Can we add methods to the SDK that can handle these three APIs:
GET https://api.castle.io/v1/users/{user-id}/devices
PUT https://api.castle.io/v1/devices/{device_token}/approve
PUT https://api.castle.io/v1/devices/{device_token}/report
See more on each API here: https://castle.io/docs/device_management_tool
Currently in get_session there is a check, if (!$_COOKIE['_ubt']), since there is a possibility this key may not exist, php will throw an undefined index error. I believe this should be:
if ( !isset($_COOKIE['_ubt']) )
I have composer setup and working correctly. I am using the dev-master version simply for testing purposes and every single time I get the following error.
Class 'Castle' not found
Looking through the composer auto-load files I have come to the conclusion that the composer.json is not set correctly.
As per php manual, getenv takes a string argument:
Currently verify_settings() is taking constants, getenv(USERBIN_APP_ID), I believe these should be wrapped with single quotes.
Hi guys, I need your help. I'm using this castle-php library for my project and I have a problem. I already followed the documentation here https://castle.io/docs/events for PHP but still I can't log events in my castle. I tried creating a file just to isolate and just run castle and here's my code. The problem here is that I have an error which asks for headers but its said in the documentation that headers are set automatically for server side SDK's like PHP.
Here's the error message:
[01-Jun-2017 06:31:51 Europe/Athens] PHP Fatal error: Uncaught exception 'Castle_BadRequest' with message 'One or more HTTP headers are missing: header 'X-Castle-Cookie-Id' is missing' in /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php:81 Stack trace: #0 /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php(116): Castle_Request->handleApiError(Array, 400) #1 /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php(162): Castle_Request->handleResponse(Object(Castle_RequestTransport)) #2 /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Castle.php(101): Castle_Request->send('post', '/track', Array) #3 /home/stgngstm/public_html/info.php(25): Castle::track(Array) #4 {main} thrown in /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php on line 81
Here's my Code:
`<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/stm-libraries/castle-php/lib/Castle.php';
Castle::setApiKey('myapikeyhere');
$verdict = Castle::authenticate(array(
'name' => '$login.succeeded',
'user_id' => '20007a'
));
if ($verdict->action == 'allow') {
echo 'Allowed';
Castle::identify('20007a', array(
'traits' => array(
'name' => 'Rey Philip Regis',
'_region' => 'NCR',
'email' => '[email protected]'
)
));
Castle::track(array(
'name' => 'My important event',
'user_id' => '20007a'
));
} else if ($verdict->action == 'challenge') {
// Additional authentication required
echo 'Challenge';
} else if ($verdict->action == 'deny') {
echo 'Denied';
// Failed authentication. Lock account
}
?>`
Hope you guys can help me. Thanks.
After trying to login Castle will though a CURL error related to the SSL Chain having a Self Signed Cert in it. To be specific it troughs this error:
60: SSL certificate problem: self signed certificate in certificate chain
Is $html .= "ubin(" legal when $html is not defined in the scope yet?
Curiosity was sparked when I received this error when trying to include:
Message: Undefined variable: html
Filename: userbin/Userbin.php
Line Number: 118
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.