private function privateFunctionGetGoogleAnalyticsData($hdIndicadorId, $tableId, $fec_ini, $fec_fin, $attr_id) { $access_token = $this->useRefreshToken($hdIndicadorId); $atributo = DetNetworkAttributePeer::retrieveByPK($attr_id); $keyword = $atributo->getAttribute()->getKeyWord(); $postdata = http_build_query(array('ids' => $tableId, 'metrics' => $keyword, 'start-date' => $fec_ini, 'end-date' => $fec_fin, 'max-results' => '1', 'access_token' => $access_token)); $xml_string = @file_get_contents("https://www.google.com/analytics/feeds/data" . "?" . $postdata); $resp = 0; if ($xml_string === FALSE) { $resp = 0; } else { $xml = simplexml_load_string($xml_string); if (isset($xml->entry)) { $metrics = $xml->entry->xpath("dxp:metric"); if ($metrics[0]['value'] != '') { $resp = $metrics[0]['value']; } else { $resp = 0; } } else { $resp = 0; } } return $resp; }
$(a).css("border","1px solid #BFBFBF"); } var networks = [ <?php foreach ($networks as $network) { ?> { name: '<?php echo $network->getName(); ?> ', models: [ <?php $c = new Criteria(); $c->add(DetNetworkAttributePeer::NETWORK_ID, $network->getId()); $atributos = DetNetworkAttributePeer::doSelect($c); ?> <?php $count_attr = count($atributos); ?> <?php $c = 1; ?> <?php foreach ($atributos as $atributo) { ?> { id: '<?php echo $atributo->getAttributeId(); ?> ', keyword: '<?php echo $atributo->getAttribute()->getKeyWord();
private function getIndicatorScData($indicator_sc_id) { $nodo = IndicatorsScPeer::retrieveByPk($indicator_sc_id); $det_net_attr_id = $nodo->getDetNetworkAttributeId(); $network_id = $nodo->getDetNetworkAttribute()->getNetworkId(); $usernameInNetwork = $nodo->getUsernameInNetwork(); $atributo = DetNetworkAttributePeer::retrieveByPK($det_net_attr_id); $keyword = $atributo->getAttribute()->getKeyWord(); $resp = 0; if ($network_id == '1') { /* Facebook */ $json_string = @file_get_contents("http://graph.facebook.com/" . $usernameInNetwork . "/"); if ($json_string === FALSE) { $resp = 0; } else { $json = json_decode($json_string); if (isset($json->{$keyword})) { if ($json->{$keyword} != '') { $resp = $json->{$keyword}; } else { $resp = 0; } } else { $resp = 0; } } } elseif ($network_id == '2') { /* Twitter */ $xml_string = @file_get_contents("http://api.twitter.com/1/users/show.xml?screen_name=" . $usernameInNetwork); if ($xml_string === FALSE) { $resp = 0; } else { $xml = simplexml_load_string($xml_string); if (isset($xml->{$keyword})) { if ($xml->{$keyword} != '') { $resp = $xml->{$keyword}; } else { $resp = 0; } } else { $resp = 0; } } } elseif ($network_id == '3') { /* Google Analytics */ $access_token = $this->useRefreshToken($nodo->getId()); if ($access_token != null) { $postdata = http_build_query(array('ids' => $usernameInNetwork, 'metrics' => $keyword, 'start-date' => $nodo->getGaFecFin(), 'end-date' => date("Y-m-d"), 'max-results' => '1', 'access_token' => $access_token)); $xml_string = @file_get_contents("https://www.google.com/analytics/feeds/data" . "?" . $postdata); if ($xml_string === FALSE) { $resp = 0; } else { $xml = simplexml_load_string($xml_string); if (isset($xml->entry)) { $metrics = $xml->entry->xpath("dxp:metric"); if ($metrics[0]['value'] != '') { $resp = $metrics[0]['value']; } else { $resp = 0; } } else { $resp = 0; } } } else { $resp = 0; } } return $resp; }