The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. November 21, 2008, 04:12:00 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Wordpress & pingbacks  (Read 313 times)
raimis100
n00b
*
Offline Offline

Posts: 8


View Profile
« on: August 08, 2008, 01:34:31 PM »

I am such a noob!

I want to manually send pingbacks but I can't figure out how to use this:

Code:

function doPingback( $url , $blogu, $post )
{
  require_once ('wp-includes/class-IXR.php');
  $bu = "" . $blogu;
  $client = new IXR_Client( $url );
  if(!$client->query( 'pingback.ping', $post->guid, $bu ))
  {
    //48 means the trackback/pingback has already been registered
    if($client->getErrorCode() != '48')
    {
      //var_dump('Error on ' . $url . ': pingback.ping('. $post->guid .', '. $bu . ')');
      return false;
    }
  }
  //file_put_contents(ABSPATH . '/wp-content/plugins/responses.xml', "\n\n -- \n" . $blogu .': '. var_dump($client->getResponse()));
  return $client->getResponse();
}


has anybody of you done this before ?

I tired to do it in many ways but it does not give any response
Logged
Bompa
Administrator
Expert
*****
Offline Offline

Posts: 208


View Profile WWW
« Reply #1 on: October 03, 2008, 01:50:10 AM »

I am such a noob!

I want to manually send pingbacks but I can't figure out how to use this:

Code:

function doPingback( $url , $blogu, $post )
{
  require_once ('wp-includes/class-IXR.php');
  $bu = "" . $blogu;
  $client = new IXR_Client( $url );
  if(!$client->query( 'pingback.ping', $post->guid, $bu ))
  {
    //48 means the trackback/pingback has already been registered
    if($client->getErrorCode() != '48')
    {
      //var_dump('Error on ' . $url . ': pingback.ping('. $post->guid .', '. $bu . ')');
      return false;
    }
  }
  //file_put_contents(ABSPATH . '/wp-content/plugins/responses.xml', "\n\n -- \n" . $blogu .': '. var_dump($client->getResponse()));
  return $client->getResponse();
}


has anybody of you done this before ?

I tired to do it in many ways but it does not give any response

raimis, you make any progress with this yet?

Bompa
Logged

emonk
Rookie
**
Offline Offline

Posts: 44


View Profile
« Reply #2 on: October 03, 2008, 07:41:22 AM »

 Do you have a link to the site you're sending the pingback too? You have to. Although you can just cloak the link them, usually.

 Anyhow here's my code to do it without IXR. It's way faster, if  I remember right. I know my folder has an older IXR version, so I must've rewritten it for SOME reason. Smiley

send_pingbacks.php:
Code:
<?php

send_pingback
($domain$responder$target$link);

function 
send_pingback($domain$responder$source$target) {
$source htmlspecialchars($source,  ENT_NOQUOTES);
$target htmlspecialchars($target,  ENT_NOQUOTES);

$body = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>

<methodCall>
  <methodName>pingback.ping</methodName>
  <params>
    <param>
      <value>$source</value>
      <name>sourceURI</name>
    </param>
    <param>
      <value>$target</value>
      <name>targetURI</name>
    </param>
  </params>
</methodCall>
EOT;

# Using the cURL extension to send it off,
# first creating a custom header block
//$header[] = "Host: $domain";
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($body) . "\r\n";
$header[] = $body;

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $responder); # URL to post to
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); # return into a variable
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 25);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); # custom headers, see above
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' ); # This POST is special, and uses its specified Content-type
$result = curl_exec( $ch ); # run!
curl_close($ch);

print_r($header);
echo $result;

}
?>

Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!