Hi,
I have a issue when i consume the Alfresco APIs.
I have installing Alfresco Version 5.2.0 (201707).
I want consume the Alfresco APIs with PHP. I have a code in php i use JQUERY for that. I have used JQUERY, AJAX, AXION but but none works. In console i have this issue. "Access to XMLHttpRequest at 'http://localhost:8080/alfresco/service/api/login.json?u=admin&pw=admin' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
I don't know if there is an SDK for PHP. I have used some SDK for PHP but is very OLD. Also i have added the permissions in the head and it doesn't work for me either.
This is my code. Is very simple!
<?php
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
} ?>
<html>
<head>
<script type = "text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
var surl = "http://localhost:8080/alfresco/service/api/login.json?u=admin&pw=admin";
$.ajax({
url: surl,
dataType: "json",
success: function (data) {
alert(JSON.stringify(data));
}
});
});
</script>
</head>
<body>
</body>
</html>
I hope someone can help me. Thank you.