Class: Pingback::Client
- Inherits:
-
Object
- Object
- Pingback::Client
- Defined in:
- lib/pingback/client.rb
Overview
This class allows to send pingback requests.
Instance Method Summary collapse
-
#ping(source_uri, target_uri) ⇒ String
send an pingback request to the targets associated pingback server.
Instance Method Details
#ping(source_uri, target_uri) ⇒ String
send an pingback request to the targets associated pingback server.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pingback/client.rb', line 16 def ping(source_uri, target_uri) header = request_header target_uri pingback_server = header['X-Pingback'] unless pingback_server doc = Nokogiri::HTML(request_all(target_uri).body) link = doc.xpath('//link[@rel="pingback"]/attribute::href').first pingback_server = URI.escape(link.content) if link end raise InvalidTargetException unless pingback_server send_pingback pingback_server, source_uri, target_uri end |