And So I almost possess a pingback sender ready for my rails application (people publish links to content and donate for them). Almost.

I have lent heavily in the code here: http://theadmin.org/articles/2007/12/04/mephisto-trackback-library/

I modified the slightly for my reasons:

require 'net/http'
require 'uri'

class Trackback

  @data = { }

  def initialize(link_id)
    link = Link.find(link_id)
    site = Link.website

    if link.nil?
      raise "Could not find link"
    end

    if link.created_at.nil?
      raise "link not published"
    end

    @data =  {
      :title => link.name,
      :excerpt => link.description,
      :url => "http:://www.MyApp.org/links/#{link.to_param}/donations/new",
      :blog_name => "My App"
    }
  end

  def send(trackback_url)
    u = URI.parse trackback_url
    res = Net::HTTP.start(u.host, u.port) do |http|
      http.post(u.request_uri, url_encode(@data), { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8' })
    end
    RAILS_DEFAULT_LOGGER.info "TRACKBACK: #{trackback_url} returned a response of #{res.code} (#{res.body})"
    return res
  end

  private

  def url_encode(data)
    return data.map {|k,v| "#{k}=#{v}"}.join('&')
  end

end

Appears like I am delivering links effectively to my wordpress blog however when I consider the link shown on the trackback I recieve this: http://www.theurl.com/that/my/browser/iscurrentlypointing/at/http:://www.MyApp.org/links/#/donations/new"

All I would like may be the other half of the lengthy string. Have no idea why the present location on my small browser is coming inside.

I have attempted this on a couple of my blogs therefore it does not appear to become problem associated with my wordpress installation.

UPDATE: Okay this can be a little odd: I checked the page source also it shows the right link. After I click it, however, I recieve forwarded to the strange link I pointed out above. Is a Wordpress Problem?

Whoops! Appears like it had been only a syntax error. A sneaky double colon

This line

url => "http:://www.MyApp.org/links/#{link.to_param}/donations/new"

Should obviously end up like this

url => "http://www.MyApp.org/links/#{link.to_param}/donations/new",