Как мне сделать карту Трелло с данными формы? - PullRequest
0 голосов
/ 23 декабря 2018

Я работал над тем, как сделать карту trello через мой веб-сайт, но со всеми заполненными полями он только сделает карту и ничего больше.Карта отображается в правильном списке, просто без описания или заголовка.

<!DOCTYPE html>
<html lang="en">

<?php
   ob_start();
   session_start();
?>

<?
   // error_reporting(E_ALL);
   // ini_set("display_errors", 1);
?>

    <head>
        <title>Some Major Oofery About</title>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <!-- import the webpage's stylesheet -->
        <link rel="stylesheet" href="/ohr.css">

        <!-- import the webpage's javascript file -->
        <script src="/script.js" defer></script>
      </head>

      <div class="form-createcard">
<?php
if ($_POST) {
  $card_name = htmlspecialchars($_POST['cardname']);
  $card_content = htmlspecialchars($_POST['carddesc']) . "\n";
  $card_content .= htmlspecialchars($_POST['authorname']) . "\n";
  $card_content .= htmlspecialchars($_POST['duedate']);

  $trello_key          = '---';
  $trello_api_endpoint = 'https://api.trello.com/1';
  $trello_list_id      = '---';
  $trello_member_token = '---'; // Guard this well

  $url = 'https://api.trello.com/1/cards';
  $fields='token='.$trello_member_token;
  $fields.='&key='.$trello_key;
  $fields.='&idList='.$trello_list_id;
  $fields.='&name='.$card_name;
  $fields.='&desc='.$card_content;

  $result = trello_post($url, $fields);
}

function trello_post($url, $fields){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  curl_setopt($ch, CURLOPT_HEADER, 0);    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $output = curl_exec($ch);
  curl_close($ch);
  return json_decode($output);
}
?>
</div>

    <body>
        <header class="header">

    <div class="centered">
            <h1>Create Trello Card to <a href="---">Suspensions/Some Major Oofery Board</a></h1>
            <form class = "form-createcard" role = "form" 
            action = "<?php echo htmlspecialchars($_SERVER['PHP_SELF']); 
            ?>" method = "post">
            <input id="cardname" type="text" placeholder="Card Name">
            <input id="duedate" type="date" placeholder="Due Date">
            <input id="carddesc" type="text" placeholder="Card Description">
            <input id="authorname" type="text" placeholder="Your Name">
            <button name="submit" type="submit" id="trellosubmit">Submit Entry</button>
            </form>
        <hr>
    </div>

Я знаю, что ключа / токена нет, я заблокировала их.Карта отправляет, делает карту, но заголовок и описание являются пустыми значениями.Да, это php-файл, поэтому не спрашивайте.

...