Exemplo n.º 1
0
function runQuery(&$analytics, $tableId, $startDate, $endDate, $metrics, $dimmensions = '', $sort = '', $maxResults = '1000', $filters = '', $segment = '')
{
    try {
        $params = array();
        if (!empty($dimmensions)) {
            $params['dimensions'] = $dimmensions;
        }
        if (!empty($sort)) {
            $params['sort'] = $sort;
        }
        if (!empty($filters)) {
            $params['filters'] = $filters;
        }
        if (!empty($segment)) {
            $params['segment'] = $segment;
        }
        if ($maxResults != '1000' && !empty($maxResults)) {
            $params['max-results'] = $maxResults;
        }
        $results = $analytics->data_ga->get($tableId, $startDate, $endDate, $metrics, $params);
        return $results;
    } catch (Exception $e) {
        $err = new stdClass();
        error_logger("Google Analytics Error", $e->getMessage());
        $err->ga_error = $e->getMessage();
        return $err;
    }
}
Exemplo n.º 2
0
function postAPI($url, $params = null, $headers = null, $ssl = true)
{
    $cache = APIcache($url, $params);
    if (isset($cache)) {
        $result = $cache;
    } else {
        $curl = curl_init();
        $params = http_build_query($params);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
        if (isset($headers)) {
            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        }
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_ENCODING, "gzip");
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $ssl);
        if (!($result = curl_exec($curl))) {
            $err = new stdClass();
            $err->curl_error = curl_error($curl);
            error_logger("Curl Error", curl_error($curl));
            return $err;
        }
        curl_close($curl);
        //  APIstore($url, $params, $result);
    }
    $data = json_decode($result);
    if ($data == NULL) {
        return $result;
    }
    return $data;
}
Exemplo n.º 3
0
function getTopFBPosts($account, $count = 10)
{
    $start = tryGET('start');
    $end = tryGet('end');
    $token = getFBToken();
    if (!isset($token[0])) {
        DoNotCache();
        error_logger("Facebook Error", "Authentication failed");
        return null;
    }
    //No token
    $url = "https://graph.facebook.com/{$account}/posts";
    $params = array($token[0] => $token[1], "limit" => 100, "fields" => "likes.limit(1).summary(true),shares,actions", "since" => $start, "until" => $end);
    $result = getAPI($url, $params);
    if (!isset($result->data)) {
        return array();
    }
    $rdata = $result->data;
    usort($rdata, 'fbSort');
    $posts = array();
    foreach ($rdata as $key => $p) {
        if ($key < $count) {
            array_push($posts, $p);
        } else {
            break;
        }
    }
    return $posts;
}
Exemplo n.º 4
0
function DoNotCache($reason = "")
{
    error_logger("Cache Error", $reason);
    if (isset($_SESSION["do-not-cache"])) {
        $_SESSION["do-not-cache"] += 1;
    } else {
        $_SESSION["do-not-cache"] = 1;
    }
    return null;
}
Exemplo n.º 5
0
            }
        }
    }
}
if (isset($_POST['Task']) && $_POST['Task'] == "Register") {
    try {
        $Profiles = $MyDB->get_profile_($_POST['Email'], "-");
        if (isset($Profiles) && isset($Profiles['result']) && is_array($Profiles['result'])) {
            $Profile = $Profiles['result'];
            $profile_id = $Profile['id'];
            $state = $MyDB->update_user($profile_id, $_POST['Full_Name'], $_POST['Password'], $_POST['Email'], $_POST['Phone'], $_POST['Picture']);
        } else {
            $MyDB->add_new_user($_POST['Full_Name'], $_POST['Password'], $_POST['Email'], $_POST['Phone'], $_POST['Build_phase'], $_POST['Gender'], $_POST['Country'], $_POST['Picture'], 1);
        }
        $Profiles = $MyDB->get_profile($_POST['Phone'], $_POST['Password']);
        if (isset($Profiles) && isset($Profiles['result'])) {
            $Profile = $Profiles['result'];
            $found = array();
            $found['Full_Name'] = $Profile['full_name'];
            $found['Email'] = $Profile['email'];
            $found['Phone'] = $Profile['phone'];
            $found['Password'] = $_POST['Password'];
            $found['Country'] = $Profile['phone'];
            array_push($ben['User_Profile'], $found);
        }
    } catch (Exception $e) {
        error_logger("---> " . date('Y-m-d H:i:s'));
        error_logger($e);
    }
}
echo json_encode($ben);