• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Snoopy Class and Igniter?

#1
[eluser]zimco[/eluser]
Forgive the ignorance of a newbie, but i was looking to use Code Igniter to re-write an application i had written a couple of years ago in order to easily update it and make it more readily adaptable for the future.

However, the main functions of my program rely heavily on the Snoopy.class.php and i have not seen Igniter example programs or tutorials where something like Snoopy was utilized.

Has anybody successfully incorporated Snoopy? Does anybody have a library include for Snoopy? If not, would bringing in the Snoopy.class.php be hard with Code Igniter?

#2
[eluser]xwero[/eluser]
I just checked out the snoopy class and it will not be that hard to integrate it in CI.

Name the class Snoopy.php, drop it in the application/libraries directory and you are good to go for following code
Code:
$this->load->library('snoopy');
/$this->snoopy->proxy_host = "my.proxy.host";
//$this->snoopy->proxy_port = "8080";

// set browser and referer:
$this->snoopy->agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$this->snoopy->referer = "http://www.jonasjohn.de/";

// set some cookies:
$this->snoopy->cookies["SessionID"] = '238472834723489';
$this->snoopy->cookies["favoriteColor"] = "blue";

// set an raw-header:
$this->snoopy->rawheaders["Pragma"] = "no-cache";

// set some internal variables:
$this->snoopy->maxredirs = 2;
$this->snoopy->offsiteok = false;
$this->snoopy->expandlinks = false;

// set username and password (optional)
//$snoopy->user = "joe";
//$snoopy->pass = "bloe";

// fetch the text of the website www.google.com:
if($this->snoopy->fetchtext("http://www.google.com")){
    // other methods: fetch, fetchform, fetchlinks, submittext and submitlinks

    // response code:
    print "response code: ".$this->snoopy->response_code."<br/>\n";

    // print the headers:

    print "<b>Headers:</b><br/>";
    while(list($key,$val) = each($this->snoopy->headers)){
        print $key.": ".$val."<br/>\n";
    }

    print "<br/>\n";

    // print the texts of the website:
    print "<pre>".htmlspecialchars($this->snoopy->results)."</pre>\n";

}
else {
    print "Snoopy: error while fetching document: ".$this->snoopy->error."\n";
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.