Exemplo n.º 1
0
 public static function sendOAuthBody($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $body, $more_headers = false, $signature = false)
 {
     $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
     $hash = base64_encode(sha1($body, TRUE));
     if ($signature == "HMAC-SHA256") {
         $hmac_method = new OAuthSignatureMethod_HMAC_SHA256();
         $hash = base64_encode(hash('sha256', $body, TRUE));
     }
     $parms = array('oauth_body_hash' => $hash);
     $test_token = '';
     $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL);
     $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms);
     $acc_req->sign_request($hmac_method, $test_consumer, $test_token);
     // Pass this back up "out of band" for debugging
     global $LastOAuthBodyBaseString;
     $LastOAuthBodyBaseString = $acc_req->get_signature_base_string();
     $header = $acc_req->to_header();
     $header = $header . "\r\nContent-Type: " . $content_type . "\r\n";
     if ($more_headers === false) {
         $more_headers = array();
     }
     foreach ($more_headers as $more) {
         $header = $header . $more . "\r\n";
     }
     return Net::doBody($endpoint, $method, $body, $header);
 }
Exemplo n.º 2
0
</p>
<?php 
if (!isset($_SESSION['html_data'])) {
    return;
}
$data = $_SESSION['html_data'];
unset($_SESSION['html_data']);
echo "<pre>\n";
echo "Input HTML\n";
echo htmlentities($data);
echo "\n";
// First validate using
// https://github.com/validator/validator/wiki/Service:-Input:-POST-body
$validator = 'https://validator.w3.org/nu/?out=json&parser=html5';
echo "Calling the validator {$validator} ... \n";
$return = Net::doBody($validator, "POST", $data, 'Content-type: text/html; charset=utf-8');
echo "Validator Output:\n";
echo htmlentities(jsonIndent($return));
if ($return . length > 0) {
    echo "Your code did not validate.  Please return to the W3 validator at validator.w3.org to check your code.";
} else {
    echo $data;
    $dom = new DOMDocument();
    @$dom->loadHTML($data);
    print "First check that major components are there.\n" . '<br>';
    try {
        $nodes = $dom->getElementsByTagName('html');
        if ($nodes->length == 1) {
            print "Found html tag!\n" . '<br>';
            print "...making sure English language is specified!" . '<br>';
            foreach ($nodes as $p) {