I login here to an account: https://sandbox.simpro.co
In setup/applications I created a new application. Access Type Direct Access, Signature Method HMAC-SHA1
In the file where "Application URI" points I have this:
$headers = array(
'Host: sandbox.simpro.co',
'Authorization: OAuth,oauth_version="1.0",
oauth_nonce="1d0c9d11a944b2439cf867f32d59d21b",
oauth_timestamp="1355952869",
oauth_consumer_key="sandbox-simpro-......",
oauth_signature_method="HMAC-SHA1Access",
oauth_signature="....."',
'Content-Type: application/json',
'Accept: application/json'
);
$url = 'https://sandbox.simpro.co/api/oauth/access_token.php';
$context = array(
'http' => array(
'content' => $content,
'header' => implode("
", $headers) . "
",
'method' => $method,
'timeout' => 10.0,
'ignore_errors'=>false
)
);
$response = file_get_contents(
$url, false,
stream_context_create($context));
if ($response === false){
var_dump("<hr><pre>Request Failed", array('url'=>$url, 'method'=>$method, 'headers'=>$headers, 'content'=>$content),'</pre>');
}
Nothing works. I know I'm doing everything wrong but on https://api.simpro.co/ there is no PHP example. I just don't understand how to put everything together.
How do I connect to simPro API with php?
UPDATE:
This is what I get in on my script:
Warning: file_get_contents(https://sandbox.simpro.co/api/oauth/access_token.php) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented in /.../index.php on line 64
string(23) "
Request Failed"
array(4) {
["url"]=>
string(52) "https://sandbox.simpro.co/api/oauth/access_token.php"
["method"]=>
string(4) "post"
["headers"]=>
array(4) {
[0]=>
string(23) "Host: sandbox.simpro.co"
[1]=>
string(318) "Authorization: OAuth,oauth_version="1.0",
oauth_nonce="1d0c9d11a944b2439cf867f32d59d21b",
oauth_timestamp="1355952869",
oauth_consumer_key="sandbox-simpro-.....",
oauth_signature_method="HMAC-SHA1Access",
oauth_signature="...........""
[2]=>
string(30) "Content-Type: application/json"
[3]=>
string(24) "Accept: application/json"
}
["content"]=>
string(0) ""
}
string(6) "
I understand that I don't describe in the right way my problem, that is because I'm having trouble to understand this API. Then can please give me a link to a php script where this part from https://api.simpro.co/ is used:
Request Token https://buildname.simpro.co/api/oauth/request_token.php
Authorization https://buildname.simpro.co/oauth/authorize.php
Access Token https://buildname.simpro.co/api/oauth/access_token.php
I just want to list the customers with PHP and simPRO.