AWR cloud script debuged – SEO
By Herve le turdu

Advanced web ranking AWR cloud script debuged: I have debugged The [get ranking] API call and it works fine on Wamp server 2.4

Observation: DONT’F forget to ALLOW url fopen in you php.ini

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
$project_name = "your-site.com";
//Build the request URL. Include your API token and the project name. This call retrieves
// https://www.awrcloud.com/sync.php?action=get_dates&token=your-token&project_name=your-site.com
$url = 'https://www.awrcloud.com/sync.php?action=get_dates&token=your-token&project_name='.$project_name;
 
//your-token
$response = json_decode(file_get_contents($url),true);
 
//Now we have the available update dates for the requested project as arrays containg a date value and the search depth
$dates = $response["dates"];
 
foreach ($dates as $date_item) {
    $the_date = $date_item["date"];
    $search_depth = $date_item["depth"];
 
    //Now we can list the rankings for each of those dates. You can specify the result type, which can be json or html.
    $url = "https://www.awrcloud.com/get.php?action=list&project=".$project_name."&date=".$the_date."&token=your-token&type=json&compression=zip";
    // https://www.awrcloud.com/sync.php?action=list&date=2014-01-09&token=your-token&project_name=your-site.com&type=html
 
    //echo $url = "https://www.awrcloud.com/get.php?action=list&project=your-site.com&date=".$the_date."&token=your-token&type=json";
    $s = file_get_contents($url);
    //var_dump ($s);
 
    $ranking_results_response = json_decode($s, true);
 
    //var_dump ($ranking_results_response);
 
    //$response_rows = explode("\n", $ranking_results_response);
    $response_rows = explode("\n", $s);
 
    // var_dump ($response_rows);
 
    if ($response_rows[0] == "OK") //We have results available for this date and project
    {
        $row_count = $response_rows[1]; //Check how many response files are available for this date
        if ($row_count == 0)
            continue; //We have no results for this date
 
        for ($i = 0; $i < $row_count; $i++)
        {
            $url_request =  $response_rows['2'+$i];
            //echo $url_request;
 
            $url_handle = fopen($url_request, 'r');//Open as read only. 
            // https://www.awrcloud.com/get.php?action=get&project=your-site.com&token=your-token&date=2014-01-08&type=json&compression=zip&file=0.tar.xz
            // The request returns a zip file with multiple rankings for the requested project
 
            $temp_zip = fopen("tempfile.zip", "w");
 
            while (!@feof($url_handle))
            {
                $read_chunk = fread($url_handle, 1024*8);
                fwrite($temp_zip, $read_chunk);
            }
            fclose($temp_zip);
            fclose($url_handle);
 
            $path_to_extractd_json = "./unzip/";
 
            $zip = new ZipArchive;
            $res = $zip->open('tempfile.zip');
            if ($res === TRUE) {
                $zip->extractTo($path_to_extractd_json);
                $zip->close();
            }
            else
            {
                echo "Could not extract json files from the zip archive";
                continue;
            }
 
            $dir_handle = opendir($path_to_extractd_json);
 
           // var_dump(readdir($dir_handle));
 
            //Now we can read each extracted json file and output the results
            while (false !== ($entry = readdir($dir_handle)))
            {
                //var_dump($entry); 
                $entry = $path_to_extractd_json.$entry;
                if (!is_file($entry)){ 
                continue;
                }
 
                $rankings = json_decode(file_get_contents($entry), true); //Make sure you use associative arrays since the json file contains nested json objects
                //var_dump($rankings); exit;
 
                //echo "Search Engine: ".$rankings["searchengine"];
                //echo "Search Depth: ".$rankings["depth"];
                //echo "Location: ".$rankings["location"];
                echo "Keyword: ".$rankings["keyword"];
                $rank_data_array = $rankings["rankdata"];
 
                foreach ($rank_data_array as $rank_data)
                {
                        if (stripos($rank_data["url"], "pricerunner")){
                    echo $rank_data["position"].". ".$rank_data["url"]." result on page ".$rank_data["page"];
                    echo "<br>";
                    }
                } 
            }
        }
    }
    else
    {
        echo "No results for date=".$the_date;
    }
}
?>

More info on AWRCLOUD API can be found on their site. The Update action allow to tag your keywords and is very handy but I haven’ tested the script yet. Good coding!

http://www.advancedwebranking.com/online/developer-api.html

Get the best prices on the web



RECENTLY BLOGGED ABT

TWEETS

  • My twitter:

Test of NS:

I will try to insert different elements into it:

Broken TWiTTs :(

  •  

AUTHOR

  • Hervé Le TurduMy name is Herve Le Turdu.
    I am a 32 years old french* man with an inquiring mind and an enthusiastic personality. Get to know me better !

    *Pardon my English tainted with a strong accent and of many mistakes

Projects & Work

LINKS - BeCause they deserve it!

I Love SEOgadget ----------------------------------------------------
Testing stuff:
http://leturdu.com/2014/01/awr-cloud-script-debuged/

Test 1 // show post ID: 530

Test 2 // show category page: SEO