|
| Re: eBay api? |
 |
Tue, 1 Apr 2008 11:45:48 -0800 |
Hello,
I don't know the eBay API that well but I've written clients that interact
with the service. Here's some code from one of our tests.
const
//{$DEFINE PRODUCTION_GATEWAY}
{$IFDEF PRODUCTION_GATEWAY}
defURL = 'https://api.ebay.com/wsapi';
{$ELSE}
defURL = 'https://api.sandbox.ebay.com/wsapi';
{$ENDIF}
VERSION = '485';
ENDPOINT = defURL + '?callname=';
SITEID = '0';
function getEbayInterface(Rio: THTTPRIO; callname: string):
eBayAPIInterface;
function Token: string;
begin
Result := GetWSToken('eBay', 'TOKEN');
end;
function AppID: string;
begin
Result := GetWSToken('eBay', 'APPID');
end;
function DevID: string;
begin
Result := GetWSToken('eBay', 'DEVID');
end;
function CertID: string;
begin
Result := GetWSToken('eBay', 'CERTID');
end;
var
SecurityHdr: RequesterCredentials; // eBay security header
Credentials: UserIdPasswordType; // eBay credentials
begin
SecurityHdr := RequesterCredentials.Create;
Credentials := UserIdPasswordType.Create;
SecurityHdr.eBayAuthToken := Token;
SecurityHdr.Credentials := Credentials;
SecurityHdr.Credentials.AppId := AppID;
SecurityHdr.Credentials.DevId := DevID;
SecurityHdr.Credentials.AuthCert := CertID;
Rio.SOAPHeaders.Send(SecurityHdr);
Rio.SOAPHeaders.SetOwnsSentHeaders(True);
Rio.URL := EndPoint;
Result := Rio as eBayAPIInterface;
RIO.Converter.Options := RIO.Converter.Options + [soDontSendEmptyNodes];
Rio.URL := ENDPOINT + callname +
'&siteid=0' +
'&appid=' + AppID +
'&version=' + VERSION +
'&Routing=new';
end;
procedure InitRequest(Request: AbstractRequestType);
var
DetLevel: Array_Of_DetailLevelCodeType;
begin
SetLength(DetLevel, 1);
DetLevel[0] := DetailLevelCodeType.ReturnAll;
Request.DetailLevel := DetLevel;
Request.ErrorLanguage := 'en_US';
Request.Version := VERSION;
Request.ErrorHandling := ErrorHandlingCodeType.BestEffort;
end;
The GetWSToken call above retrieves the credentials we received from eBay
when we signed up.
Here's a sample method that invokes the simple 'GeteBayOfficialTime' method:
procedure TTesteBay.geteBayTime(RIO: THTTPRIO);
var
req: GeteBayOfficialTimeRequest;
service: eBayAPIInterface; // eBay interface
res: GeteBayOfficialTimeResponse;
ebTime, myTime: TDateTime;
begin
service := getEbayInterface(RIO, 'GeteBayOfficialTime');
req := GeteBayOfficialTimeRequest.Create();
try
InitRequest(req);
res := service.GeteBayOfficialTime(req);
try
myTime := Now;
ebTime := res.Timestamp.AsDateTime;
if (Abs(ebTime - myTime) > 1) then
begin
raise Exception.Create('Suspicious time received from eBay');
end;
if Length(res.Version) <> 3 then
begin
raise Exception.CreateFmt('Suspicious reply from eBay - version:
%s', [res.Version]);
end;
if Length(res.Build) < 1 then
begin
raise Exception.Create('Suspicious reply from eBay');
end;
finally
res.Free;
end;
finally
req.Free;
end;
end;
Keep in mind that this is testing code. We're just ensuring that we can
correctly communicate with eBay - not doing any useful. Since we're located
in PST, we ensure that the time we received matches our curret time.
We also do searches and retrieve API Access Rules.
Let me know if you have questions about any of the above. I can probably
answer or find someone who can.
Cheers,
Bruneau.
|
| Post Reply
|
| eBay api? |
 |
Tue, 01 Apr 2008 17:52:15 +010 |
Hi,
Has anyone any experience of working with the eBay API using SOAP?
I am struggling to get started and really could do with a few pointers
particularly which internet connection utils I should use i.e. Indy
components?
I am wanting to write a desktop application that gets info from eBay and
am asuming the eBay SOAP utils are the best option for this.
I'm using cogear RAD Studio 2007 Architect on Windows XP if this helps any.
Any suggestions would be gratefully appreciated
|
| Post Reply
|
| Re: eBay api? |
 |
Tue, 01 Apr 2008 21:47:40 +010 |
It looks like this may be exactly what I am looking for.
I'l have a good look at it and se how I get on.
Many thanks.
James
Jean-Marie Babet wrote:
> Hello,
>
> I don't know the eBay API that well but I've written clients that interact
> with the service. Here's some code from one of our tests.
>
> const
> //{$DEFINE PRODUCTION_GATEWAY}
> {$IFDEF PRODUCTION_GATEWAY}
> defURL = 'https://api.ebay.com/wsapi';
> {$ELSE}
> defURL = 'https://api.sandbox.ebay.com/wsapi';
> {$ENDIF}
>
> VERSION = '485';
> ENDPOINT = defURL + '?callname=';
> SITEID = '0';
>
> function getEbayInterface(Rio: THTTPRIO; callname: string):
> eBayAPIInterface;
>
> function Token: string;
> begin
> Result := GetWSToken('eBay', 'TOKEN');
> end;
>
> function AppID: string;
> begin
> Result := GetWSToken('eBay', 'APPID');
> end;
>
> function DevID: string;
> begin
> Result := GetWSToken('eBay', 'DEVID');
> end;
>
> function CertID: string;
> begin
> Result := GetWSToken('eBay', 'CERTID');
> end;
>
> var
> SecurityHdr: RequesterCredentials; // eBay security header
> Credentials: UserIdPasswordType; // eBay credentials
> begin
> SecurityHdr := RequesterCredentials.Create;
> Credentials := UserIdPasswordType.Create;
>
> SecurityHdr.eBayAuthToken := Token;
> SecurityHdr.Credentials := Credentials;
> SecurityHdr.Credentials.AppId := AppID;
> SecurityHdr.Credentials.DevId := DevID;
> SecurityHdr.Credentials.AuthCert := CertID;
>
> Rio.SOAPHeaders.Send(SecurityHdr);
> Rio.SOAPHeaders.SetOwnsSentHeaders(True);
> Rio.URL := EndPoint;
>
> Result := Rio as eBayAPIInterface;
>
> RIO.Converter.Options := RIO.Converter.Options + [soDontSendEmptyNodes];
>
> Rio.URL := ENDPOINT + callname +
> '&siteid=0' +
> '&appid=' + AppID +
> '&version=' + VERSION +
> '&Routing=new';
> end;
>
> procedure InitRequest(Request: AbstractRequestType);
> var
> DetLevel: Array_Of_DetailLevelCodeType;
> begin
> SetLength(DetLevel, 1);
> DetLevel[0] := DetailLevelCodeType.ReturnAll;
> Request.DetailLevel := DetLevel;
> Request.ErrorLanguage := 'en_US';
> Request.Version := VERSION;
> Request.ErrorHandling := ErrorHandlingCodeType.BestEffort;
> end;
>
>
> The GetWSToken call above retrieves the credentials we received from eBay
> when we signed up.
>
> Here's a sample method that invokes the simple 'GeteBayOfficialTime'
method:
>
> procedure TTesteBay.geteBayTime(RIO: THTTPRIO);
> var
> req: GeteBayOfficialTimeRequest;
> service: eBayAPIInterface; // eBay interface
> res: GeteBayOfficialTimeResponse;
> ebTime, myTime: TDateTime;
> begin
> service := getEbayInterface(RIO, 'GeteBayOfficialTime');
> req := GeteBayOfficialTimeRequest.Create();
> try
> InitRequest(req);
> res := service.GeteBayOfficialTime(req);
> try
> myTime := Now;
> ebTime := res.Timestamp.AsDateTime;
>
> if (Abs(ebTime - myTime) > 1) then
> begin
> raise Exception.Create('Suspicious time received from eBay');
> end;
>
> if Length(res.Version) <> 3 then
> begin
> raise Exception.CreateFmt('Suspicious reply from eBay - version:
> %s', [res.Version]);
> end;
>
> if Length(res.Build) < 1 then
> begin
> raise Exception.Create('Suspicious reply from eBay');
> end;
> finally
> res.Free;
> end;
> finally
> req.Free;
> end;
> end;
>
>
>
> Keep in mind that this is testing code. We're just ensuring that we can
> correctly communicate with eBay - not doing any useful. Since we're
located
> in PST, we ensure that the time we received matches our curret time.
>
> We also do searches and retrieve API Access Rules.
>
> Let me know if you have questions about any of the above. I can probably
> answer or find someone who can.
>
> Cheers,
>
> Bruneau.
>
>
>
|
| Post Reply
|
| Re: eBay api? |
 |
Wed, 02 Apr 2008 03:11:35 +010 |
Hi,
I presume I need to import the eBaySvc.wsdl in order to get access to
the eBayAPIInterface?
I have never used SOAP or this functionality before so I would be
grateful if you have any other pointers for me.
Thanks
James
Jean-Marie Babet wrote:
> Hello,
>
> I don't know the eBay API that well but I've written clients that interact
> with the service. Here's some code from one of our tests.
>
> const
> //{$DEFINE PRODUCTION_GATEWAY}
> {$IFDEF PRODUCTION_GATEWAY}
> defURL = 'https://api.ebay.com/wsapi';
> {$ELSE}
> defURL = 'https://api.sandbox.ebay.com/wsapi';
> {$ENDIF}
>
> VERSION = '485';
> ENDPOINT = defURL + '?callname=';
> SITEID = '0';
>
> function getEbayInterface(Rio: THTTPRIO; callname: string):
> eBayAPIInterface;
>
> function Token: string;
> begin
> Result := GetWSToken('eBay', 'TOKEN');
> end;
>
> function AppID: string;
> begin
> Result := GetWSToken('eBay', 'APPID');
> end;
>
> function DevID: string;
> begin
> Result := GetWSToken('eBay', 'DEVID');
> end;
>
> function CertID: string;
> begin
> Result := GetWSToken('eBay', 'CERTID');
> end;
>
> var
> SecurityHdr: RequesterCredentials; // eBay security header
> Credentials: UserIdPasswordType; // eBay credentials
> begin
> SecurityHdr := RequesterCredentials.Create;
> Credentials := UserIdPasswordType.Create;
>
> SecurityHdr.eBayAuthToken := Token;
> SecurityHdr.Credentials := Credentials;
> SecurityHdr.Credentials.AppId := AppID;
> SecurityHdr.Credentials.DevId := DevID;
> SecurityHdr.Credentials.AuthCert := CertID;
>
> Rio.SOAPHeaders.Send(SecurityHdr);
> Rio.SOAPHeaders.SetOwnsSentHeaders(True);
> Rio.URL := EndPoint;
>
> Result := Rio as eBayAPIInterface;
>
> RIO.Converter.Options := RIO.Converter.Options + [soDontSendEmptyNodes];
>
> Rio.URL := ENDPOINT + callname +
> '&siteid=0' +
> '&appid=' + AppID +
> '&version=' + VERSION +
> '&Routing=new';
> end;
>
> procedure InitRequest(Request: AbstractRequestType);
> var
> DetLevel: Array_Of_DetailLevelCodeType;
> begin
> SetLength(DetLevel, 1);
> DetLevel[0] := DetailLevelCodeType.ReturnAll;
> Request.DetailLevel := DetLevel;
> Request.ErrorLanguage := 'en_US';
> Request.Version := VERSION;
> Request.ErrorHandling := ErrorHandlingCodeType.BestEffort;
> end;
>
>
> The GetWSToken call above retrieves the credentials we received from eBay
> when we signed up.
>
> Here's a sample method that invokes the simple 'GeteBayOfficialTime'
method:
>
> procedure TTesteBay.geteBayTime(RIO: THTTPRIO);
> var
> req: GeteBayOfficialTimeRequest;
> service: eBayAPIInterface; // eBay interface
> res: GeteBayOfficialTimeResponse;
> ebTime, myTime: TDateTime;
> begin
> service := getEbayInterface(RIO, 'GeteBayOfficialTime');
> req := GeteBayOfficialTimeRequest.Create();
> try
> InitRequest(req);
> res := service.GeteBayOfficialTime(req);
> try
> myTime := Now;
> ebTime := res.Timestamp.AsDateTime;
>
> if (Abs(ebTime - myTime) > 1) then
> begin
> raise Exception.Create('Suspicious time received from eBay');
> end;
>
> if Length(res.Version) <> 3 then
> begin
> raise Exception.CreateFmt('Suspicious reply from eBay - version:
> %s', [res.Version]);
> end;
>
> if Length(res.Build) < 1 then
> begin
> raise Exception.Create('Suspicious reply from eBay');
> end;
> finally
> res.Free;
> end;
> finally
> req.Free;
> end;
> end;
>
>
>
> Keep in mind that this is testing code. We're just ensuring that we can
> correctly communicate with eBay - not doing any useful. Since we're
located
> in PST, we ensure that the time we received matches our curret time.
>
> We also do searches and retrieve API Access Rules.
>
> Let me know if you have questions about any of the above. I can probably
> answer or find someone who can.
>
> Cheers,
>
> Bruneau.
>
>
>
|
| Post Reply
|
| Re: eBay api? |
 |
Wed, 2 Apr 2008 09:10:11 -0800 |
> I presume I need to import the eBaySvc.wsdl in order to get access to
> the eBayAPIInterface?
Yes, you'll need to import the WSDL. If you have an earlier version of
Delphi, make sure to grab the importer/runtime updates here:
http://cc.codegear.com/Item/24535
eBay utilizes/exposes some schema featuresthat the earlier importer/runtime
did not support.
Cheers,
Bruneau.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|