首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RingCentral接口请求

RingCentral接口请求
EN

Stack Overflow用户
提问于 2019-11-12 14:00:51
回答 1查看 97关注 0票数 0

我正在尝试向RingCentral API发送请求。文档的链接是https://developers.ringcentral.com/api-reference/Fax/createFaxMessage如果我没有指定faxResolutioncoverIndex,一切都很顺利,可以发送传真。但是如果我像下面的代码一样添加faxResolution参数,我会收到与coverIndex参数相同的error "Parameter [faxResolution] value is invalid", "errorCode" : "CMN-101".。我的客户是GuzzleHttp 6.3

代码语言:javascript
复制
    $token = $this->ringcentral->platform()->auth()->data()['access_token'];
    $a = array();
    foreach ($destination_numbers as $number) {
        $a[] = [
            'name' => 'to',
            'contents' =>  $number,
            'headers' => ['Content-Type' => 'multipart/form-data']
        ];
    }
    $a[] = [
            'name' => 'faxResolution',
            'contents' => 'High',
            'headers' => ['Content-Type' => 'multipart/form-data']
        ];
    foreach ($attachments as $attachment) {
        $file_pointer = fopen($attachment, 'r');
        $mime = mime_content_type($attachment);
        $a[] = [
            'name' => 'attachment',
            'contents' => $file_pointer,
            'headers' => ['Content-Type' => $mime]
        ];
    }
    $client = new Client();
    try {
        $response = $client->request('POST', url(config('services.ringcentral.app_url')) . '/restapi/v1.0/account/~/extension/~/fax', [
            'headers' => [
                'Accept' => 'application/json',
                'Authorization' => 'Bearer ' . $token
            ],
            'multipart' => $a
        ]);
        $response = json_decode($response->getBody(), true);
    } catch (\GuzzleHttp\Exception\ClientException $e) {
        echo($e->getResponse()->getBody()->getContents());
    }
EN

回答 1

Stack Overflow用户

发布于 2020-02-22 02:48:37

下面是RingCentral在使用PHP时的建议。我包含了他们所有的建议,但只需看看关于faxResolution的部分(下降了2/3)

代码语言:javascript
复制
    <?php
// https://developers.ringcentral.com/my-account.html#/applications
// Find your credentials at the above url, set them as environment variables, or enter them below

// PATH PARAMETERS
$accountId = '<ENTER VALUE>';
$extensionId = '<ENTER VALUE>';

$recipient = '<ENTER VALUE>';

require('vendor/autoload.php');
$rcsdk = new RingCentral\SDK\SDK(getenv('clientId'), getenv('clientSecret'), getenv('serverURL'));
$platform = $rcsdk->platform();
$platform->login(getenv('username'), getenv('extension'), getenv('password'));

$request = $rcsdk->createMultipartBuilder()
    ->setBody(array(
     'to' => array(array('phoneNumber' => $recipient)),
     'faxResolution' => 'High',
    ))
    ->add(fopen('fax.jpg', 'r'))
    ->request("/restapi/v1.0/account/{$accountId}/extension/{$extensionId}/fax");

$r = $platform->sendRequest($request);
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58812895

复制
相关文章

相似问题

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