通过 PHP 的 easybill REST API POST

这是我在此的头一篇博文。我希望我的问题是正确的。我使用谷歌翻译器从德语到英语,因为我的英语不太好。

我想使用 easybill 的“api”。得到工作。但不幸的是我不能用 POST 来做到这一点。

我希望有一个人可以帮助我。

我想创建一个新客户进行测试。我的目标是稍后使用 PHP 生成发票。easybill 的“api”可以在这里找到: https: //www.easybill.de/api/

我尝试了以下代码,但不幸的是我找不到错误。


holdtom
浏览 67回答 1
1回答

慕的地8271018

$url = "https://api.easybill.de/rest/v1/customers";$data =  array(              'first_name'   => 'Foo',          'last_name'    => 'Bar',          'company_name' => 'FooBar GmbH',          'emails'       => array ('foo.bar@foobar.com'            ));$postdata = json_encode(array($data));$accesstoken = "XXXXXXXXXXX";$headr = array();$headr[] = 'Content-length: 0';$headr[] = 'Content-type: application/json';$headr[] = 'Authorization: Bearer '.$accesstoken;    $ch = curl_init($url);    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    curl_setopt($ch, CURLOPT_POST, 1);    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);    curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);    $result = curl_exec($ch);    curl_close($ch);    print_r ($result);来自德国的最诚挚的问候。
打开App,查看更多内容
随时随地看视频慕课网APP