Php Podio API拉取错误数据

Php Podio API拉取错误数据,php,api,podio,Php,Api,Podio,我有一个叫做考勤的应用程序。在该应用程序项中,我有一个名为“#个人”的数字字段和一个校园关系字段。我正在按校园计算所有个人的总数,但由于某种原因,我的Podio报告中显示的总数没有正确地与API挂钩 例如:Pelham路(podio)=69121菲律宾比索(API)=60776 以下是给出错误号码的代码: <?php error_reporting(0); require_once 'podio/PodioAPI.php';

我有一个叫做考勤的应用程序。在该应用程序项中,我有一个名为“#个人”的数字字段和一个校园关系字段。我正在按校园计算所有个人的总数,但由于某种原因,我的Podio报告中显示的总数没有正确地与API挂钩

例如:Pelham路(podio)=69121菲律宾比索(API)=60776

以下是给出错误号码的代码:

<?php
            error_reporting(0);
            require_once 'podio/PodioAPI.php';

            function codigo_fuente($url){
                $url = file($url);
                $codigo = '';
                foreach ($url as $numero => $linea) { 
                    $codigo .= '#<strong>' .$numero . '</strong> : ' . htmlspecialchars($linea) . '<br />';
                }
                return $codigo;
            }

            try {
                $weekday=30;
            foreach($_GET as $key => $value){
              //echo $key . " : " . $value . "<br />\r\n";
                    $weekday=$key;
                 }
              //  echo $weekday;


             Podio::setup("api key goes here", "api secret goes here");
            Podio::authenticate_with_password("usermail goes here", "user pass goes here");
            //Podio::authenticate_with_app("app id goes here", "app token goes here");
            $year = date("Y");
            $array1 = array();
            $array2 = array();
            $opt="";
            $name1="$month1 $FromDayLast/$ToDayLast, $yearLast";
            $name2="$month2 $FromDayActual/$ToDayActual, $yearActual";
            //echo "Name1 is".$name1;
            //echo "Name2 is ".$name2;
            $tabla="<table width=70%>
             <tr>
             <td style=width: 10%; font-size: 7pt;  valign=top><strong></strong></td>
               <td style=width: 10%; font-size: 7pt;  valign=top><strong></strong></td>
               <td style=width: 10%; font-size: 7pt;  valign=top><strong>$columna1</strong></td>
               <td style=width: 10%; font-size: 7pt;  valign=top><strong>$columna2</strong></td>
               <td style=width: 10%; font-size: 7pt;  valign=top><strong>$columna3</strong></td>
               <td style=width: 10%; font-size: 7pt;  valign=top><strong>$columna4</strong></td>
               <td style=width: 10%; font-size: 7pt;  valign=top><strong>$columna5</strong></td>

              </tr>
              ";



            $valores="";  $totalesLast1=""; $totalesLast2=""; $totalesLast3=""; $totalesActual="";
            $campaign = PodioItem::filter(8900539, array( 'sort_by' => 'title',
                                                            'sort_desc' => false)); // Get items from app with app_id=123
            $cant=0; $tot=0;
            foreach ($campaign as $item) {
                //echo "<br/>*************************************************<br/>";
             // echo "<br/>title::".$item->title;
              //echo "<br/>ID::".$item->item_id;

              $se=false;$se1=false;$se2=false;
                if($item->title=="Other"){
                  $se=true;
                }
                if($item->title=="Offsite"){
                    $se1=true;
                }
                if($item->title=="Central"){
                    $se2=true;
                }

                if($se==false && $se1==false && $se2==false){

              $cant = $cant +1;
                $tabla=$tabla."<tr>

               <td style=width: 20%; font-size: 7pt;  valign=top>"
              .$cant."</td>";



              $tabla=$tabla."<td style=width: 20%; font-size: 7pt;  valign=top>"
              .$item->title."</td>";

               $valores=$valores."|".$item->title;

                $app_reference_field_id = 116781926; 
               $attendancetype = 116781927;
               $date =  116781925;
               $adult = 9;
               $fourSeven = 10;
               $Fusion = 6;
               $Forge = 7;
               $WideOpen = 2;
               $Nursery = 5;
               $Preschool = 4;
               $Elementary = 8;

             //$date_lead_created=101404311;m
             $filter_target_item_id = $item->item_id;

            $attendance1 = PodioItem::filter(15171541, array( 'limit' => 400, 'offset' => 0, 
                  'filters' => array(
                    $app_reference_field_id => array($filter_target_item_id),
                    $date  => array(
                                      'from' => date("Y-m-d H:i:s", strtotime("01/01/$year")), 'to' => date("Y-m-d H:i:s")
                                    )
                  ),
                  'limit' => 200, 'offset' => $offset
                ));
                $valor = 0;

                if($attendance1->filtered>0){
                    $sum =0;
                    foreach($attendance1 as $item){

                        $sum = $sum + $item->fields["total-attendance"]->values;        
                                  //  echo "<br>Sum is ".$sum."<br>";
                    }

                    $weekNumber = date("W"); 
                            if($weekday==0)
                                $weekday=$weekNumber;
                    //$weekNumber = $weekNumber -1; 
                         //   echo "The Week Number is ".$weekNumber;
                    $valor = round(($sum/$weekday));
                       //  echo $sum."<br>";
                }else{
                    $valor = 0;
                }
                $totales = $totales.",".$valor;
                 $tot= $tot + $valor;
                $tabla=$tabla."<td style=width: 10%; font-size: 7pt;  valign=top>".$valor."</td>";
                }   
            }

            $tabla=$tabla."</table>";

            $totalesLast1 = substr($totalesLast1,0,strlen($totalesLast1)-1);
            $totalesLast2 = substr($totalesLast2,0,strlen($totalesLast2)-1);
            $totalesLast3 = substr($totalesLast3,0,strlen($totalesLast3)-1);
            //$totalesActual = substr($totalesActual,0,strlen($totalesActual)-1);

            //$totalesLast = $totalesLast ."|".$totalesActual;
            echo $tabla;

            //echo "<br/>totales::::$totalesLast";

            //print_r($array1);
            //print_r($array2);

            $mayor1 = $array1[12];
            $mayor2 = $array2[12];
            $mayor="";
            if($mayor1>$mayor2){
                $mayor=$mayor1;
            }else{
                $mayor=$mayor2;
            }

            $valores = substr($valores,1,strlen($valores)-1);
            $valores = str_replace(" ","%20",$valores);
            $name1 = str_replace(" ","%20",$name1);
            $name2 = str_replace(" ","%20",$name2);

            $columna1 = str_replace(" ","%20",$columna1);
            $columna2 = str_replace(" ","%20",$columna2);
            $columna3 = str_replace(" ","%20",$columna3);
            $columna4 = str_replace(" ","%20",$columna4);
            $columna5 = str_replace(" ","%20",$columna5);

            $valores = substr($valores,0,strlen($valores));
            $valores = str_replace(" ","%20",$valores);
            //echo $valores."<br/>";
            $totales = substr($totales,1,strlen($totales)-1);
            //echo $totales."<br/>";

            $totales2 = str_replace(",","|",$totales);

            $totaless="";
            $varr = explode(",",$totales);
            foreach($varr as $tt){
                //echo "<br/>valor::".$tt;
                $v1= $tt*100;
                $v2= $v1/$tot;
                $totaless = $totaless.",".$v2;
            }
            $totaless = substr($totaless,1,strlen($totaless)-1);

            $url = "https://chart.googleapis.com/chart?cht=p3&chs=700x300&chd=t:$totaless&chl=$totales2&chdl=$valores&chco=FFFF10,FF0000,0072c6|ef3886|ff9900";
            //$url = "https://chart.googleapis.com/chart?cht=p3&chs=250x100&chd=t:60,40&chl=Hello|World";
            //echo $url;

            if(@copy($url, 'cinco.png')){
            //echo "image-saved";
            //echo "http://aparicio.website/uno.png";
            }else{
            //echo "failed"; 
            }

            }



            catch (PodioError $e) {
             echo "error $e"; // Something went wrong. Examine $e->body['error_description'] for a description of the error.
            }

            ?>

看起来您的
PodioItem::filter
调用正在使用不同的值设置两次“limit”和“offset”,并且您正在引用未设置的
$offset
变量。这意味着您要传递null作为偏移量。不确定这是否是问题所在,但这可能不是你想要的


此外,您正在舍入值
$valor=round(($sum/$weekday))
,因此
$weekday
可能不是您所期望的,您从
$\u GET
中获取
$weekday
作为
$key
的方式可能也不是您想要的。

看起来您的
PodioItem::filter
调用使用不同的值设置了两次“limit”和“offset”,并且您引用了一个未设置的
$offset
变量。这意味着您要传递null作为偏移量。不确定这是否是问题所在,但这可能不是你想要的


此外,您正在舍入值
$valor=round(($sum/$weekday))
,因此
$weekday
可能不是您所期望的,并且您从
$\u GET
中获得
$weekday
的方式可能也不是您想要的。

嗨,John,这个“论坛”的目的是是对编程问题给予帮助和指导。如果你需要一般的帮助,我建议你提交一张关于。如果你的问题与API或SDK的使用有关,你应该提供更多信息给我们以帮助你(例如,你在做什么,你的代码到目前为止,你遇到的错误,等等。)Hi@domokun我已经这样做了,他们在这里指给我。我不确定你们需要什么信息来帮助我。你的报告是如何配置的?此外,您显示的代码缺少一些上下文。您是如何填充$attendance1的?@ChrisPeters Podio我已经将所有代码放在上面了。嗨,John,这个“论坛”的目的是在编程问题上提供帮助和指导。如果你需要一般的帮助,我建议你提交一张关于。如果你的问题与API或SDK的使用有关,你应该提供更多信息给我们以帮助你(例如,你在做什么,你的代码到目前为止,你遇到的错误,等等。)Hi@domokun我已经这样做了,他们在这里指给我。我不确定你们需要什么信息来帮助我。你的报告是如何配置的?此外,您显示的代码缺少一些上下文。您是如何填充$attendance1的?@ChrisPeters-Podio我已经将所有代码放在上面了