Revision: 64671
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 5, 2013 20:12 by kundi
Initial Code
<?php /* RankTrackr PHP Snippet | SEO Rank Tracker This snippet will take search rankings (urls) from your RankTrackr account (http://ranktrackr.com) */ //enable error reporting error_reporting(E_ERROR | E_WARNING | E_PARSE); class RankTrackr { public $token; public $username = '[email protected]'; public $password = 'password'; public $host = 'http://users.ranktrackr.com/api/v1/'; public $ch; public function __construct() { $this->ch = curl_init(); } function get_auth_token() { $query = $this->host . 'token'; $this->ch = curl_init(); curl_setopt_array($this->ch, array( CURLOPT_URL => $query, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => "email=$this->username&password=$this->password" )); $data = curl_exec($this->ch); if (!$data) { return false; } $object = json_decode($data); //var_dump( $object ); if ($object && $object->access_token) { $this->token = $object->access_token; } return true; } function get_all_urls() { $params = array( 'access_token' => $this->token ); $query = $this->host . 'urls?' . http_build_query($params); $this->ch = curl_init(); curl_setopt_array($this->ch, array( CURLOPT_URL => $query, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array('Content-Type: application/json') )); $data = curl_exec($this->ch); //$info = curl_getinfo($this->ch); if (!$data) { return false; } var_dump ( $data ); $object = json_decode($data); var_dump ( $object ); return $object; } } // Example usage: $ranks = new RankTrackr(); $ranks->get_auth_token(); $ranks->get_all_urls();
Initial URL
http://ranktrackr.com
Initial Description
RankTrackr PHP Snippet | SEO Rank Tracker This snippet will take search rankings (urls) from your RankTrackr account (http://ranktrackr.com) and allow you get data from your tracked urls / keywords.
Initial Title
Search Engine Rank Tracker - RankTrackr Access Snippet
Initial Tags
Initial Language
PHP