Mysmilies.net die Smilies Datenbank

Script oder Datei finden :

 
-Startseite
-Newsarchiv
-Newsletter
-Mein Dreamcodes
-Scripte
-eBooks
-Online Speicher
-Datenbanken
-Webseiten
-Trickfilm
-Web Grafiken
-Bildbearbeiter
-Browser
-EMail Software
-Ftp Clienten
-Betriebssysteme
-Texteditoren
-Wampserver
-Office Pakete
-Antivirus
-System Cleaner
-Recovery Tools
-Php Schnipsel
-Ajax Schnipsel
-VB Schnipsel
-Tutorials
-Workshops
-Webkatalog
-Leserforum
-Erweiterte Suche
-Sitemap
-Impressum
-neuste Downloads

1. Selfphp (1851)
2. Xampp OS X (1737)
3. Xampp Linux (1726)
4. Xampp Windows (1750)

-neuste Tutorials

1. Samsung S20 rooten (2175)
2. Gratis USA Nummer (15923)
3. RAID (14740)
4. Text auf Grafik (15591)


Tutorials Adsense Grabber

 

Adsense Grabber

PHP AdSense account monitor class, can retrieve data from your AdSense account (impressions, clicks, ctr, ecpm, earnings).

This class can retrieve (for now) only "AdSense for Content" data, for different periods of time (see class methods for more details). You can implement this PHP class in your own applications.

 
Script:

Source code for AdSense.php

<?php
class AdSense {


    /**
     * Stores curl connection handle
     *
     * @var resource
     */
    var $curl = null;


    /**
     * Stores TMP folder path
     * This folder must be writeble
     *
     * @var string
     */
    var $tmpPath = '/tmp';


    /**
     * AdSense::AdSense()
     * AdSense class constructor
     */
    function AdSense(){
        $this->coockieFile = tempnam($this->tmpPath, 'cookie');

        $this->curl = curl_init();
        curl_setopt($this->curl, CURLOPT_HEADER, false);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($this->curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7");
        curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookieFile);
        curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookieFile);

        register_shutdown_function(array(&$this, '__destructor'));
    }


    /**
     * AdSense::__destructor()
     * AdSense class destructor
     */
    function __destructor(){
        @curl_close($this->curl);
        @unlink($this->coockieFile);
    }


    /**
     * AdSense::connect()
     * Connects to AdSense account using supplied credentials
     * Returns true on unsuccessful connection, false otherwise
     *
     * @param string $username AdSense username
     * @param string $password AdSense password
     * @return boolean
     */
    function connect($username, $password){
        // phase 1
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginAuth?service=adsense&hl=en-US&ltmpl=login&ifr=

true&passive=true&rm=hide&nui=3&alwf=true&continue=https%3A%2F%2Fwww.google.com%2Fadsense%

2Fgaiaauth&followup=https%3A%2F%2Fwww.google.com%2Fadsense%2Fgaiaauth");
        preg_match_all('<input type="hidden" name="(.*?)" value="(.*?)">', curl_exec($this->curl), $out);
        $params = array();
        foreach($out[1] as $key=>$name) { $params[] = $name . '=' . urlencode($out[2][$key]); }
        $params[] = 'Email=' . urlencode($username);
        $params[] = 'Passwd=' . urlencode($password);
        $params[] = 'null=' . urlencode('Sign in');

        // phase 2
        curl_setopt($this->curl, CURLOPT_POST, true);
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginAuth");
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, join('&', $params));
        preg_match("/.*<a target=\"_top\" href=\"(.*)\" style.*/", curl_exec($this->curl), $matches);

        // phase 3
        curl_setopt($this->curl, CURLOPT_POST, false);
        curl_setopt($this->curl, CURLOPT_URL, $matches[1]);

        // did we login ?
        if (eregi("Log out", curl_exec($this->curl))) {
            return true;
        } else {
            return false;
        };
    }


    /**
     * AdSense::parse()
     * Parses AdSense page and gets all stats
     * Returns associative array with collected data
     *
     * @param string $content AdSense page content
     * @return array
     */
    function parse($content){
        preg_match_all('/<td nowrap valign="top" style="text-align:right" class="">(.*?)<\/td>/', $content, $matches);
        return array(
            "impressions" => $matches[1][0],
            "clicks" => $matches[1][1],
            "ctr" => $matches[1][2],
            "ecpm" => $matches[1][3],
            "earnings" => $matches[1][4]
        );

    }


    /**
     * AdSense::today()
     * Gets AdSense data for the period: today
     * Returns associative array with collected data
     *
     * @return array
     */
    function today(){
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=today");
        return $this->parse(curl_exec($this->curl));
    }


    /**
     * AdSense::yesterday()
     * Gets AdSense data for the period: yesterday
     * Returns associative array with collected data
     *
     * @return array
     */
    function yesterday(){
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=yesterday");
        return $this->parse(curl_exec($this->curl));
    }


    /**
     * AdSense::last7days()
     * Gets AdSense data for the period: last7days
     * Returns associative array with collected data
     *
     * @return array
     */
    function last7days(){
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=last7days");
        return $this->parse(curl_exec($this->curl));
    }


    /**
     * AdSense::lastmonth()
     * Gets AdSense data for the period: lastmonth
     * Returns associative array with collected data
     *
     * @return array
     */
    function lastmonth(){
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=lastmonth");
        return $this->parse(curl_exec($this->curl));
    }


    /**
     * AdSense::thismonth()
     * Gets AdSense data for the period: thismonth
     * Returns associative array with collected data
     *
     * @return array
     */
    function thismonth(){
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=thismonth");
        return $this->parse(curl_exec($this->curl));
    }


    /**
     * AdSense::sincelastpayment()
     * Gets AdSense data for the period: sincelastpayment
     * Returns associative array with collected data
     *
     * @return array
     */
    function sincelastpayment(){
        curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=sincelastpayment");
        return $this->parse(curl_exec($this->curl));
    }

}

?>

Source code for example.php

<?php

include('AdSense.php');

$adsense = new AdSense();
if ($adsense->connect('username', 'password')) {
    $data = $adsense->sincelastpayment();
} else {
    die('Could not login to AdSense account.');
};

?>

 
Seiten : 1
hinzugefügt am : 29.10.2007
Autor : Na
Listings ID : 1484
Status zum lesen : Gast
gelesen : 8149 mal
[Druckansicht] [Lesercharts] [RSS] [zur Übersicht]
 
 

Die Möglichkeit diesen Artikel zu verlinken :

HTML-Code:

Code zum Einbinden in ein Forum:


Hinweis : Das lesen des Artikels Adsense Grabber - listings ID: 1484 auf Dreamcodes, sowie Link Verweise auf Internetseiten fremder Anbieter erfolgen auf eigene Gefahr. Dreamcodes haftet nicht für Schäden, die aus der Verwendung des Inhaltes der Artikel erfolgen könnten. Schadenersatzansprüche, aus welchem Rechtsgrund auch immer, sind ausgeschlossen !
-Live Statistik
Datum: 24.11.2024
Uhrzeit: 12:19 Uhr
Online: 5 User
User heute: 10466
User allgem.: 35349542

Eingeloggt als Gast
-Download des Monats
-
-unsere Monats Umfrage
Welche Serie ist besser?

The Blacklist
House of the Dragon
Die Ringe der Macht
The Sandman
Manifest

-unsere Bestseller