0

因此,我正在尝试从我公司网页上填写的表格中创建一张带有 zen 办公桌的票。我是一家初创公司的实习生,我以前从未编写过 php,实际上只有 java。我正在尝试将我们网页上填写的表格连接到我们的消息中 zen 桌面子域,但我真的不明白逻辑。这是我所拥有的:

                <?php 
                echo $this->Session->flash();
                ?>
                <form id="facebook-pass-signup" class="form-horizontal sign-up-form pk-form-validate" action="<?php echo $this->Html->url("/forms/post/");  
            define("ZDAPIKEY", "keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey");  
            define("ZDUSER", "me@example.com");  
            define("ZDURL", "https://myzdaccount.zendesk.com/api/v2");
            function curlWrap($url, $json)
            {
             $ch = curl_init();
               curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
               curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
               curl_setopt($ch, CURLOPT_URL, ZDURL.$url);
               curl_setopt($ch, CURLOPT_USERPWD, ZDUSER."/token:".ZDAPIKEY);
               curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
               curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
               curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
               curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
               curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
               curl_setopt($ch, CURLOPT_TIMEOUT, 10);
               $output = curl_exec($ch);
               curl_close($ch);
               $decoded = json_decode($output);
               return $decoded;
            }
        $arr = array(  
        "new\_req\_name" => $\_POST["req\_name"],  
        "new\_req\_email" => $\_POST["req\_email"],  
        "new\_tick\_group" => "20546933",  
        "new\_tick\_assignee" => "346228388",  
        "new\_tick\_subj" => $\_POST["subject"],  
        "new\_tick\_desc" => $\_POST["tick\_desc"]  
                    );

    $create = json\_encode(  
    array(  
    'ticket' => array(  
    'requester' => array(  
    'name' => $arr['new\_req\_name'],  
    'email' => $arr['new\_req\_email']  
                        ),  
    'group\_id' => $arr['new\_tick\_group'],  
    'assignee\_id' => $arr['new\_tick\_assignee'],  
    'subject' => $arr['new\_tick\_subj'],  
    'description' => $arr['new\_tick\_desc']  
                     )  
         ),  
    JSON\_FORCE\_OBJECT 
                    );

$data = curlWrap("/tickets.json", $create, "POST");  
var\_dump($data);
print $data->ticket->id;  
print "\n";
                  ?>" method="post"> 
              <input type="hidden" name="pk-subject" value="Facebook Pass Signup"/>
              <h2 class="center text-dark-blue"><?php echo __("Sign Up Today")?></h2>
              <p class="center"><?php echo __("Our team will follow up with you on your request.")?></p>
              <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                  <input id="name" name="z_name" placeholder="Name" class="form-control input-md pk-mandatory" required type="text">
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                  <input id="email" name="z_requester" placeholder="Email" class="form-control input-md pk-mandatory pk-valid-email" required type="text">
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                  <input id="company" name="z_company"  placeholder="Company" class="form-control input-md pk-mandatory" required type="text">
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                  <textarea id="message" name="z_description" class="form-control" placeholder="Let us know if you have any questions."></textarea>
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                  <?php 
                    $this->Captcha->render($captchaSettings);
                  ?>
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-offset-1 col-sm-10">
                  <button type="submit" class="btn btn-form-submit btn-block">Submit</button>
                </div>
              </div>
            </form>
        </div>
4

0 回答 0