使用PHP和simPro API列出客户 [英] Use php and simPro API to list customers

查看:335
本文介绍了使用PHP和simPro API列出客户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我登录这里一笔账: https://sandbox.simpro.co

在设置/应用程序我创建了一个新的应用程序。访问类型直接访问,签名方法HMAC-SHA1

In setup/applications I created a new application. Access Type Direct Access, Signature Method HMAC-SHA1

在文件,其中应用程序URI点我有这样的:

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("\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例。我只是不知道如何把一切融合在一起。

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.

如何用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列出的客户。

I just want to list the customers with PHP and simPRO.

推荐答案

可能是值得考虑一下的例子code,我们提供在GitHub上:

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

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

此PHP的示例包括使用OAuth和数据的简单请求simPRO API的基本连接。

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.

这篇关于使用PHP和simPro API列出客户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆