Récuperer les informations Alexa

WRInaute discret
Bonjour

Sur les fiches détaillées des outils My WRI, on peut voir les informations fournies par Alexa => Ranking du trafic, visiteurs, liens etc...

Pouvez-vous me dire comment faire pour récupérer et afficher ces infos d'Alexa ?
J'aimerai faire un tableau dans une page web avec différents url de site et leur PR Google et info Alexa.
J'ai trouvé un script pour afficher le PR Google, mais pour Alexa, je sèche !

J'avais déjà demandé de l'info mais sans succès => https://www.webrankinfo.com/forum/t/script-alexa.53336/
 
WRInaute accro
'faut utiliser leur Web services
il y a un lien sur la page d'accueil
tu dois donner ton n° Visa car c'est payant au délà d'un certain nombre de requêtes
 
WRInaute discret
Salut Ecocentric

Comme précisé dans https://www.webrankinfo.com/forum/t/script-alexa.53336/ j'ai suivi tes conseils, me suis inscrit sur Amazon pour obtenir les infos et codes nécessaires. J'ai ma clé et mon code secret, et les informations fournies par Alexa sont claires pour obtenir le résultat escompté.
Voici le texte fournis avec le fichier :

-------------------------------------------------------------------------
- PHP REST Code Signing Sample -
-------------------------------------------------------------------------
This test will take your Access Key ID and Secret Key, assemble and make
REST requests to the Alexa Web Information Service (AWIS).

Required php 4.0.2 or higher

Steps:
1. Sign up for an Amazon Web Services account at http://aws.amazon.com
(Note that you must have a valid credit card)
2. Get your Access Key ID and Secret Access Key
3. Sign up for the Alexa Web Information Service at http://aws.amazon.com/awis
4. Uncompress the zip file into a working directory
5. Edit the urlinfo.php file and paste in your Access Key ID and Secret Access Key
6. Run
php urlinfo.php


If you are getting "Not Authorized" messages, you probably have one of the
following problems:

1. Your access key or secret key were not entered properly. Please re-check
that they are correct.

2. You did not sign up for AWIS at http://aws.amazon.com/awis
(After you have your keys, you must still separately sign up for AWIS)

3. Your credit card was not authorized. You must use a valid credit card
or your requests will not be authorized.

If you are getting "Request Expired" messages, please check that the time
is properly set on your computer.

Et voici le code de la page urlinfo.php
Code:
<?php

// Make a request to the AWIS UrlInfo operation to get information about a given url

define("ACCESS_KEY", "--- Replace with your access key id ---");
define("SECRET_ACCESS_KEY", "--- Replace with your secret access key ---");

define("SERVICE", "AlexaWebInfoService");
define("OPERATION", "UrlInfo");
define("RESPONSE_GROUP", "Rank");

$site_url = "yahoo.com";

echo("For site: " . $site_url."\n\n");

$awis_url = generate_rest_url($site_url);

echo ("Request: \n". $awis_url."\n\n");

// Make request

$result = make_http_request($awis_url);

// Display resulting XML

echo("Response:\n");
echo($result);

// Returns the AWS rest url to get AWIS information for the given site

function generate_rest_url($site_url) {

        $timestamp =  generate_timestamp();
        $site_enc = urlencode($site_url);
        $timestamp_enc = urlencode($timestamp);
        $signature_enc = urlencode (
            calculate_RFC2104HMAC
                    (SERVICE . OPERATION . $timestamp, SECRET_ACCESS_KEY)
            );

        return  "http://awis.amazonaws.com/onca/xml?"
                        . "Service=".SERVICE
                        . "&Operation=".OPERATION
                        . "&AWSAccessKeyId=".ACCESS_KEY
                        . "&ResponseGroup=".RESPONSE_GROUP
                        . "&Timestamp=$timestamp_enc"
                        . "&Signature=$signature_enc"
                        . "&Url=$site_enc";

}


// Calculate signature using HMAC: http://www.faqs.org/rfcs/rfc2104.html

function calculate_RFC2104HMAC ($data, $key) {
    return base64_encode (
        pack("H*", sha1((str_pad($key, 64, chr(0x00))
        ^(str_repeat(chr(0x5c), 64))) .
        pack("H*", sha1((str_pad($key, 64, chr(0x00))
        ^(str_repeat(chr(0x36), 64))) . $data))))
     );
}

// Timestamp format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

function generate_timestamp () {
    return gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
}

// Make an http request to the specified URL and return the result

function make_http_request($url){
       $ch = curl_init($url);
       curl_setopt($ch, CURLOPT_TIMEOUT, 4);
	   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       $result = curl_exec($ch);
       curl_close($ch);
       return $result;
}


?>

J'ai simplement insérer mon Access Key ID et mon Secret Access Key (recopié sans erreur) mais pourtant, j'obtiens ce résultat => http://www.lululelutin.com/urlinfo.php

??
 
WRInaute discret
Pour curl, faut-il ajouter une information dans cette partie du code ?

Code:
// Make an http request to the specified URL and return the result

function make_http_request($url){
       $ch = curl_init($url);
       curl_setopt($ch, CURLOPT_TIMEOUT, 4);
	   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       $result = curl_exec($ch);
       curl_close($ch);
       return $result;
}

Pourtant, dans les infos fournies, il est dit d'ajouter simplement id et clé secrète !
 
Discussions similaires
Haut