title: Why is this accept invite php script not working (discord api and curl)
body: <p>At the end it says: Json deserialize error: key must be a string at line 1 column 2</p>
  
  <p>I've tried a bunch of different things but they all don't work. I can't recall all of them and I'm pretty bad at this kind of stuff, so I wanted help</p>
  
  <pre class="lang-php prettyprint-override"><code>$url = 'https://discordapp.com/api/v6/invites/' . $_GET["invite"] . '?with_counts=true';
  
  $ch = curl_init();
  $payload = json_encode($payload);
  curl_setopt_array($ch, array(
      CURLOPT_URL            =&gt; $url,
      CURLOPT_HTTPHEADER     =&gt; array('Authorization: ' . $_GET["token"]),
      CURLOPT_RETURNTRANSFER =&gt; 1,
      CURLOPT_FOLLOWLOCATION =&gt; 1,
      CURLOPT_VERBOSE        =&gt; 1,
      CURLOPT_SSL_VERIFYPEER =&gt; 0
  ));
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/json',
      'Referer: https://discordapp.com/channels/@me'
  ));
  $response = curl_exec($ch);
  fclose($f);
  curl_close($ch);
  echo $response;
  $data = json_decode($response);
  
  echo "&lt;br/&gt;&lt;br/&gt;";
  
  $url = 'https://discordapp.com/api/v6/science';
  $data = json_decode($response);
  $json = '{channel_id: "' . $data-&gt;channel-&gt;id . '", channel_type: "0", client_performance_cpu: 48.87893460435096, client_performance_memory: 833620, client_send_timestamp: ' . time() . ', client_track_timestamp: ' . time() . ', client_uuid: "IQAECB1soghXJlZ+EXiHFG4BAAATAwAA", code: "' . $_GET["invite"] . '", destination_user_id: null, guild_id: "' . $data-&gt;guild-&gt;id  . '", invite_type: "Server Invite", inviter_id: "' . $data-&gt;inviter-&gt;id  . '", location: "Join Guild Modal", resolved:, true size_online: ' . $data-&gt;approximate_presence_count . ', size_total: ' . $data-&gt;approximate_member_count . ', type: "resolve_invite", token: "' . $_GET["token"] . '"';
  $ch = curl_init();
  $payload = json_decode($json);
  $json = $json . "}";
  
  echo $json;
  
  curl_setopt_array($ch, array(
      CURLOPT_URL            =&gt; $url,
      CURLOPT_HTTPHEADER     =&gt; array('Authorization: ' . $_GET["token"]),
      CURLOPT_RETURNTRANSFER =&gt; 1,
      CURLOPT_FOLLOWLOCATION =&gt; 1,
      CURLOPT_VERBOSE        =&gt; 1,
      CURLOPT_SSL_VERIFYPEER =&gt; 0,
      CURLOPT_POSTFIELDS     =&gt; $json
  ));
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/json',
      'Content-Length: ' . strlen($json)
  ));
  
  $response = curl_exec($ch);
  fclose($f);
  curl_close($ch);
  echo "&lt;br/&gt;&lt;br/&gt;" . $response;
  ?&gt;
  
  </code></pre>
  
  <p>The response is</p>
  
  <pre><code>Json deserialize error: key must be a string at line 1 column 2
  </code></pre>