为了账号安全,请及时绑定邮箱和手机立即绑定

通过 PHP 的 easybill REST API POST

通过 PHP 的 easybill REST API POST

PHP
holdtom 2023-11-03 20:12:29
这是我在此的头一篇博文。我希望我的问题是正确的。我使用谷歌翻译器从德语到英语,因为我的英语不太好。我想使用 easybill 的“api”。得到工作。但不幸的是我不能用 POST 来做到这一点。我希望有一个人可以帮助我。我想创建一个新客户进行测试。我的目标是稍后使用 PHP 生成发票。easybill 的“api”可以在这里找到: https: //www.easybill.de/api/我尝试了以下代码,但不幸的是我找不到错误。
查看完整描述

1 回答

?
慕的地8271018

TA贡献1796条经验 获得超4个赞

$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);

来自德国的最诚挚的问候。


查看完整回答
反对 回复 2023-11-03
  • 1 回答
  • 0 关注
  • 65 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信