dtpf76658 2014-06-22 13:57
浏览 22
已采纳

使用php和simPro API列出客户

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.

  • 写回答

1条回答 默认 最新

  • du42561 2014-06-26 03:53
    关注

    Might be worth taking a look at the example code we provide on GitHub:

    https://github.com/simPRO-Software/simpro-api-php

    This PHP example includes a basic connection to the simPRO API using OAuth and a simple request of data.

    Please let me know if you need any further info or assistance.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能