我在此处登录了一个帐户:https://sandbox.simpro.co
在设置/应用程序中,我创建了一个新应用程序。访问类型直接访问,签名方法HMAC-SHA1
在“应用程序URI”指向的文件中,我有:
$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("\r\n", $headers) . "\r\n",
'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>');
}
没有任何作用。我知道我做错了但是在https://api.simpro.co/上没有PHP示例。我只是不明白如何把所有东西放在一起。
如何使用php连接到simPro API?
更新:
这是我在剧本中的内容:
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) "
我知道我没有以正确的方式描述我的问题,因为我无法理解这个API。那么请给我一个php脚本的链接,其中使用https://api.simpro.co/的这个部分:
请求令牌 https://buildname.simpro.co/api/oauth/request_token.php
授权 https://buildname.simpro.co/oauth/authorize.php
访问令牌 https://buildname.simpro.co/api/oauth/access_token.php
我只想用PHP和simPRO列出客户。
答案 0 :(得分:2)
可能值得一看我们在GitHub上提供的示例代码:
https://github.com/simPRO-Software/simpro-api-php
此PHP示例包含使用OAuth与simPRO API的基本连接以及简单的数据请求。
如果您需要任何进一步的信息或帮助,请与我们联系。