neosaleem / seostats

Automatically exported from code.google.com/p/seostats
0 stars 0 forks source link

Bing Site Index and Site Array #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have added Bing support for anyone who wants it by adding a class called 
seostats.bing.php

file: seostats.bing.php

<?php
    /**
     *  PHP class SEOstats
     *
     *  @class      SEOstats_Bing
     *  @package    class.seostats
     *  @updated    2011/04/29
     *  @author     Chris Alvares <mail@chrisalvares.com>
     *  @copyright  2010-present, Chris Alvares/Stephan Schmitz
     *  @license    GNU General Public License (GPL)
     */

class SEOstats_Bing extends SEOstats {

    /**
     * Returns the total amount of pages for a Domain indexed at Yahoo!
     *
     * @access      private
     * @link        http://www.bing.com:80/developers/      Get your own application ID here
     * @return      integer                 Returns the total amount of pages for a Domain indexed at Bing
     */     
    public static function bingSiteIndexTotal($uri)
    {
        $url = 'http://api.bing.net/json.aspx?&Version=2.2&Market=en-US&Sources=web&Web.Count=1&JsonType=function';

        $url .= '&AppId=' . BING_APP_ID;
        $url .= '&Query=site:' . urlencode($uri);

        $str  = SEOstats::cURL($url);

        $str = str_ireplace("function BingGetResponse(){return", "", $str);     
        $str = str_ireplace("; /* pageview_candidate */}", "", $str);

        $data = json_decode($str);
        return $data->SearchResponse->Web->Total;   
    }

        /**
     * Returns array, containing details about the pages indexed at Yahoo!
     *
     * @access      private
     * @link        http://www.bing.com:80/developers/      Get your own application ID here
     * @return      array                   Returns array, containing details about the pages indexed at Bing
     */     
    public static function bingSiteindexArray($uri)
    {
        $url = 'http://api.bing.net/json.aspx?&Version=2.2&Market=en-US&Sources=web&Web.Count=50&JsonType=function';

        $url .= '&AppId=' . BING_APP_ID;
        $url .= '&Query=site:' . urlencode($uri);

        $str  = SEOstats::cURL($url);
        $str = str_ireplace("function BingGetResponse(){return", "", $str);     
        $str = str_ireplace("; /* pageview_candidate */}", "", $str);

        $data = json_decode($str);

        $result = array();

        foreach($data->SearchResponse->Web->Results as $entry)
        {
            $result[] =  array( 'Title' => $entry->Title,
                                  'URL' => $entry->DisplayUrl,
                            'Click URL' => $entry->Url);        
        }
        return $result;   
    }

}
?>

class.seostats.php
    /**
     * @access      public
     * @return      integer                 Returns the total amount of pages for the domain, indexed at Yahoo!.
    */  
    public function Bing_Siteindex_Total()
    {
        return SEOstats_Bing::bingSiteindexTotal($this->host);      
    }

    /**
     * Limited to 50 results.
     *
     * @access      public
     * @return      integer                 Returns array, containing the keys 'Title', 'URL' and 'Click URL'.
     */ 
    public function Bing_Siteindex_Array()
    {
        return SEOstats_Bing::bingSiteindexArray($this->host);      
    }   

class.seostats.config.php

define('BING_APP_ID', 'BING_API_KEY_HERE'); //can be found here: 
http://www.bing.com:80/developers/appids.aspx

Original issue reported on code.google.com by CAlva...@gmail.com on 5 Jul 2011 at 5:10

GoogleCodeExporter commented 9 years ago
Great show - big thanks! I will add that to the next release. You may allow me 
to refer to my post here 
http://code.google.com/p/seostats/issues/detail?id=18#c5, i just posted  2 
minutes ago. There you'll find some general updates. bb! 

Original comment by eyecatchup@gmail.com on 7 Jul 2011 at 8:59

GoogleCodeExporter commented 9 years ago

Original comment by eyecatchup@gmail.com on 7 Jul 2011 at 9:08

GoogleCodeExporter commented 9 years ago
Don't forget to add to modules.php:
include_once('seostats.bing.php');

Keep Performing,
Moshe Kaplan

Original comment by mokp...@gmail.com on 2 Aug 2011 at 9:25

GoogleCodeExporter commented 9 years ago
Implemented in GitHub repo.

Original comment by eyecatchup@gmail.com on 4 Aug 2011 at 1:43