cURL获取API数据以显示在php表中

ManiacSnail:

我有很多广告活动使用此api,我需要显示上个月的特定广告活动,例如广告活动的名称和状态,但我不知道该怎么做。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Campaign Exclude App</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<h1>Campaigns</h1><br>
<input type="text" name="" id="">
<input type="submit">
<table class="table">
  <thead class="thead-dark">
    <tr>
      <th scope="col">Id</th>
      <th scope="col">Campaign Name</th>
      <th scope="col">CPA Goal</th>
      <th scope="col">Click Amount</th>
    </tr>
  </thead>
</table>

<?php
$url='https://www.popads.net/api/campaign_list?key=9a790b65025e0aa449e60384a87b56e97c3ebf39';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$resultArray = json_decode($result);
echo "<pre>";
print_r($resultArray);
?>
</body>
</html>

图片已添加

manikisidana:

要列出最近30天内的记录,您可以按以下方式过滤卷曲响应

<?php
$url = 'https://www.popads.net/api/campaign_list?key=9a790b65025e0aa449e60384a87b56e97c3ebf39';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$resultArray = json_decode($result, true);
?>

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Campaign Exclude App</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>

<body>
    <h1>Campaigns</h1><br>
    <input type="text" name="" id="">
    <input type="submit">
    <table class="table">
        <thead class="thead-dark">
            <tr>
                <th scope="col">Id</th>
                <th scope="col">Campaign Name</th>
                <th scope="col">CPA Goal</th>
                <th scope="col">Click Amount</th>
            </tr>
            <?php
            $today = date('Y-m-d h:i:s');
            $lastmonth = date('Y-m-d h:i:s', strtotime('-1 months', strtotime($today)));
            foreach ($resultArray['campaigns'] as $campaign) {
                if ($campaign['created'] > $lastmonth) {

            ?>
                    <tr>
                        <td scope="col"><?php echo $campaign['id']; ?> </td>
                        <td scope="col"><?php echo $campaign['name']; ?></td>
                        <td scope="col"><?php echo $campaign['xxxxxxx']; ?></td>
                        <td scope="col"><?php echo $campaign['xxxxxxx']; ?></td>
                    </tr>
            <?php }
            } ?>
        </thead>
    </table>


</body>

</html>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

从表中获取数据以纯文本形式显示

如何使用循环从表中抓取数据以使用python获取所有td数据

React-如何获取更新的数据以显示在表中?

如何从数据库中的表中获取所有数据并使用php显示呢?

难过 如何从axios获取vue中的数据以进行显示?

在获取数据后如何获取更新后的数据以显示在vue中

从php Admin获取数据以进行显示

使用ajax和dataType:“ json”从数据库中获取数据以html形式显示

Servoy-从数据库表获取所有数据以显示为列表

React JS-从渲染表中的行获取数据以编辑数据

查询以从3个不同的表中获取数据以获取具有计数的不同键

PHP Curl获取数据

从3个表中获取数据并显示mysql php

如何显示我从API获得的数据以反应材料数据表

如何使用reactjs在表中显示从api获取的数据

如何在Vue.js中使用Chart.js从API获取数据以显示图表

如何显示从mysql获取的表中的数据?

使用cURL在PHP中获取api数据

从哈希中获取额外的序列数据以显示在highstock的工具提示中

如何编写应该从数据库获取数据以在C#中的表单上显示的方法

如何编写查询以从某些表中获取数据以获取视图模型列表?

试图获取表数据以显示在两行而不是一行上

Laravel:从相关表中获取/显示数据

mysql无法获取空数据以显示在查询中

如何从模型函数中获取数据以显示在 Django Admin 中?

加载从 CSV 列中获取的 JSON 数据以填充表

如何从mongodb中获取聚合数据以在ejs中显示?

如何从数据库中获取数据并在php中显示到表行跨度

从我的 json 文件中获取数据以显示在我的 Blade.php 中