使用跟踪器网络API

时间:2018-10-28 15:40:34

标签: php api curl

我正在尝试使用the Tracker network API向CoD bo4请求一些球员数据。我只是无法正常工作,而他们没有提供文档的事实也无济于事。 这是我的代码:

<?php
$data = $connection->query ( "SELECT * FROM bfplayers" );
$index = 0;
$curly = array();
$result = array();
$mh = curl_multi_init();
while ( ($row = mysqli_fetch_assoc ( $data )) ) {
    $psnid = $row ['psnid'];
    $id[$index] = $row['id'];
    $country[$index] = $row['country'];
    $curly[$index] = curl_init();
    curl_setopt($curly[$index], CURLOPT_URL, sprintf('https://cod-api.tracker.gg/api/v1/standard/%s/profile/%s/%s', 'bo4', '2', $psnid));
    curl_setopt($curly[$index], CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curly[$index], CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curly[$index], CURLOPT_ENCODING, '');
    curl_setopt($curly[$index], CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curly[$index], CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
    curl_setopt($curly[$index], CURLOPT_HTTPHEADER, array ('TRN-Api-Key: MYKEY'));
    curl_multi_add_handle($mh, $curly[$index]);

    $index++;
}

$running = null;
  do {
    curl_multi_exec($mh, $running);
  } while($running > 0);


  // get content and remove handles
  foreach($curly as $id => $c) {
    $result[$id] = curl_multi_getcontent($c);
    curl_multi_remove_handle($mh, $c);
  }

  // all done
  curl_multi_close($mh);

  var_dump($result);
?>

这将返回:{“ message”:“找不到具有这些值的API”} 有人看到我在做什么错吗?

0 个答案:

没有答案