代码之家  ›  专栏  ›  技术社区  ›  Owais Aslam

未通过php api提交至zendesk票证表单的所有字段数据

  •  1
  • Owais Aslam  · 技术社区  · 7 年前

    this api库,我正在成功创建zendesk票证,但问题是我无法将所有表单字段发送到zendesk票证表单。只有主题和描述字段数据通过我的代码发送。

    这是我的网络表单 This is my web form

    这是我的机票单 enter image description here

    这是我的机票清单 enter image description here

    这是我创建票证的代码

     public function CreateTicketOnZendesk($subject,$email,$description,$transactionNumber){
        try{
            $client = $this->zendesk();
                 $newTicket = $client->tickets()->create([
                     'subject'  => $subject,
                     'comment'  => [
                         'body' => $description
                     ],
                     'custom_fields'=>[
                         'email'  => $email,
                         'transaction_number'  => $transactionNumber,
                     ],
                     'priority' => 'normal'
                 ]);
                 return true;
        }catch(\Exception $e){
            error_log($e->getMessage());
        }
     }
    

    但无法发送电子邮件和交易编号字段数据。尝试添加这些字段,如发送主题。

    1 回复  |  直到 7 年前
        1
  •  3
  •   Owais Aslam    7 年前

    自定义字段应作为 id value custom_fields . 要获取字段id,您可以转到zendesk上的“票证字段”面板,也可以使用此api api/v2/ticket_fields.json

     'custom_fields'=>[
                         [
                             'id'=> '<email_field_id>', 
                             'value'=> $email
                         ],
                         [
                             'id'=> '<transaction_number_field_id>',
                             'value'=> $transactionNumber
                         ]
     ],
    
    推荐文章