Skip to content

Instantly share code, notes, and snippets.

@hayakawa
Last active August 29, 2015 13:57
Show Gist options
  • Save hayakawa/9578643 to your computer and use it in GitHub Desktop.
Save hayakawa/9578643 to your computer and use it in GitHub Desktop.
Wordpress XML-RPC Pingback checker
<?php
if ($argc != 2 or empty($argv[1])) {
echo "Usage : $argv[0] {CHECK TARGET}\n";
echo "Example: $argv[0] http://www.example.com/wp/xmlrpc.php\n";
exit(1);
} elseif (!preg_match("/^(http|https):\/\//",$argv[1])) {
echo "Invalid URL\n";
exit(1);
}
$request = xmlrpc_encode_request('pingback.ping',array('127.0.0.1', str_replace(array('http://','https://'), '', $argv[1])));
$context = stream_context_create(array('http' => array(
'method' => 'POST',
'header' => 'Content-Type: text/xml',
'content' => $request
)));
echo "[Request]\n";
print_r($request);
echo "\n";
echo "[Response]\n";
$file = file_get_contents($argv[1], false, $context);
$response = xmlrpc_decode($file);
if ($response) {
print_r($response);
} else {
echo "No response...\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment