skip to Main Content

I’ve been looking around a bit for how to get the time off of ebay..
I don’t want to use SAVON because… well it didn’t work..

So I’m trying to use net/http, just to get the time. (for now)

Here’s what I got so far.

 def get_ebay_time
require "net/http"
require "uri"

devName = 000000000
appName = 000000000
certName = 000000000
authToken = 0000000000

url = URI.parse("https://api.ebay.com/ws/api.dll")

req = Net::HTTP::Post.new(url.path)
req.add_field("X-EBAY-API-COMPATIBILITY-LEVEL", "759")
req.add_field("X-EBAY-API-DEV-NAME", devName)
req.add_field("X-EBAY-API-APP-NAME", appName)
req.add_field("X-EBAY-API-CERT-NAME", certName)
req.add_field("X-EBAY-API-SITEID", "0")
req.add_field("X-EBAY-API-CALL-NAME", "GeteBayOfficialTime")

req.body = '<?xml version="1.0" encoding="utf-8"?>'+
            '<GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">'+
            '<RequesterCredentials>'+
            "<eBayAuthToken>#{authToken}</eBayAuthToken>"+
            '</RequesterCredentials>'+
            '</GeteBayOfficialTimeRequest>?'

http = Net::HTTP.new(url.host, url.port)
res = http.start do |http_runner|
  http_runner.request(req)
end
return res.body
end

2

Answers


  1. Chosen as BEST ANSWER

    it didn't take me as long to find this as I thought.

    in the bottom bit, I added SSL handling

    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
    http.verify_mode = 0
    res = http.start do |http_runner|
      http_runner.request(req)
    end
    return res.body
    

  2. APIs wrappers are developed to help 🙂

    Please use eBay4r and same on github: up_the_irons/ebay4r

      require 'rubygems'
      gem 'ebay'
    
      # Put your credentials in this file
      load('myCredentials.rb')
    
      # Create new eBay caller object.  Omit last argument to use live platform.
      eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
    
      resp = eBay.GeteBayOfficialTime
    
      puts "Hello, World!"
      puts "The eBay time is now: #{resp.timestamp}"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search