验证身份无法访问API

时间:2018-07-21 17:38:42

标签: php api curl

我正在尝试从API检索信息。 API需要进行身份验证才能访问它。我已经尝试了以下方法,但是它说验证失败。我已经确认凭据是正确的,所以这不是问题。有什么建议吗?

$pro = '0000000000';
            $userName = 'userName';
            $password = 'password';
            $userPass = $userName.':'.$password;


            $host = 'https://wardtlctools.com/wardtrucking/webservices/imaging'; 

            $post = array(

                'User' => array(

                    'UserName' => $userName,
                    'Password' => $password

                    ),

                'Reference' => array(

                    'RefNo' => $pro,
                    'RefType' => 'WARDPRO',
                    'DelMethod' => 'Link',
                    'Documents' => array(

                        'DocType' => 'BL',
                        'DocType' => 'DR'

                        )

                    )

                );

            $ch = curl_init($host);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_TIMEOUT, 30);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
            curl_setopt($ch, CURLOPT_USERPWD, $userPass);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $return = curl_exec($ch);
            curl_close($ch);

            print_r($return);

这是提供商网站上的文档。

enter image description here

0 个答案:

没有答案