first commit
This commit is contained in:
43
api/example.php
Normal file
43
api/example.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* Example of API integration
|
||||
* --------------------------
|
||||
*
|
||||
* Pure PHP example... does not require any local RS elements (connects to RS via HTTP).
|
||||
* This code would be on a client (non ResourceSpace) system.
|
||||
*
|
||||
* For documentation please see: http://www.resourcespace.com/knowledge-base/api/
|
||||
*
|
||||
*/
|
||||
|
||||
$private_key = "e6ee5970359e1cfc24091aa7b0237feb25db1efb69a8b83d7959fb2f6b340ee0"; # <--- From RS user edit page for the user to log in as
|
||||
$user = "admin"; # <-- RS username of the user you want to log in as
|
||||
|
||||
# Some example function calls.
|
||||
#
|
||||
#$query="user=" . $user . "&function=do_search¶m1="; # <--- The function to execute, and parameters
|
||||
$query = "user=" . $user . "&function=get_resource_field_data¶m1=1"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=create_resource¶m1=1"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=update_field¶m1=1¶m2=8¶m3=Example"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=delete_resource¶m1=1"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=copy_resource¶m1=2"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=get_resource_data¶m1=2"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=get_alternative_files¶m1=2"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=get_resource_types"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=add_alternative_file¶m1=2¶m2=Test"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=get_resource_log¶m1=2"; # <--- The function to execute, and parameters
|
||||
#$query="user=" . $user . "&function=upload_file_by_url¶m1=2¶m2=¶m3=¶m4=¶m5=" . urlencode("http://www.montala.com/img/slideshow/montala-bg.jpg"); # <--- The function to execute, and parameters
|
||||
# Create resource, add a file and add metadata in one pass.
|
||||
$query = "user=" . $user . "&function=create_resource¶m1=1¶m2=¶m3=" . urlencode("http://www.montala.com/img/slideshow/montala-bg.jpg") . "¶m4=¶m5=¶m6=¶m7=" . urlencode(json_encode(array(1 => "Foo",8 => "Bar"))); # <--- The function to execute, and parameters
|
||||
|
||||
# Sign the query using the private key
|
||||
$sign = hash("sha256", $private_key . $query);
|
||||
|
||||
# Make the request.
|
||||
$results = file_get_contents("http://localhost/resourcespace/api/?" . $query . "&sign=" . $sign);
|
||||
|
||||
# Output the JSON
|
||||
echo "<pre>";
|
||||
echo escape($results);
|
Reference in New Issue
Block a user