首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Myob账号直播

Myob账号直播
EN

Stack Overflow用户
提问于 2016-07-13 18:24:55
回答 0查看 474关注 0票数 2

我正在尝试在account trying api v2的沙箱帐户中创建一个新客户。我能够使用示例php oAuth类获得访问令牌。现在,当我发送创建新客户的请求时,我得到一个403禁止响应。我用来创建客户的代码是:

代码语言:javascript
复制
    function saveContact($type, $contactId, $CoLastName, $FirstName, $IsActive, $TaxCodeId, $FreightTaxCodeId) {
    global $apiBaseURL;


    $url =  'https://ar1.api.myob.com/accountright/c3ee2b2a-6b8f-4d36-bef5-5e0c89bf104a/Contact/Customer';
    $param = '{
    "LastName": "Kumar",
    "FirstName": "Amit",
    "IsIndividual": true,
    "IsActive": true,
    "SellingDetails": {
        "TaxCode": {
            "UID": "352a8200-bf57-4723-9165-9f80429afd7d"
        },
        "FreightTaxCode": {
            "UID": "352a8200-bf57-4723-9165-9f80429afd7d"
        }
    }
}';

    // build the cftoken
  $cftoken = base64_encode('Administrator:');

      $headers = array(
        'Authorization: Bearer '.$_SESSION['access_token'],
        'x-myobapi-cftoken: '.$cftoken,
        'x-myobapi-key: '.api_key,
        'x-myobapi-version: v2',
        'Content-Type: application/json',                                                                                

    );


    $session = curl_init($url); 



//  curl_setopt ($session, CURLOPT_HTTPHEADER, $headers);

    // Tell curl to use HTTP POST
    curl_setopt ($session, CURLOPT_POST, true); 
    // Tell curl that this is the body of the POST
    curl_setopt ($session, CURLOPT_POSTFIELDS, $params); 
    // setup the authentication
    curl_setopt($session, CURLOPT_USERPWD, "Administrator:");
    curl_setopt($session, CURLOPT_HEADER, $headers); 
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    //curl_setopt(CURLOPT_SSL_VERIFYPEER, true); // enforce that when we use SSL the verification is correct



    $response = curl_exec($session); 
    var_dump($response);

    curl_close($session);

    return($response);
}

如果我遗漏了什么,请给我提一下。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38348996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档