Ruminations of an addled mind

Random ramblings about my thoughts

  • Meta

  • RSS DelphiFeeds.com

    • How to Buy My Books August 18, 2017
      First, I want to thank all of you that have bought one or more or my books.  I’m very grateful. Second, I wanted to post to make sure that everyone knows that I have three books out  and how you can buy them. Book Buy in Paperback Buy in Digital Form Buy on Amazon for $39.99 ...
      Delphi-losophy (nickhodges@gmail.com)
    • Constantly Curious – an Interview with Katrina Clokie August 18, 2017
      Congratulations on the release of your new book! Given your already prolific blogging output, conference appearances, Testing Trapeze editor role and – I assume – fairly demanding work commitments, it’s difficult not to wonder… How and where do you find the time for ...
      blog.gurock.com (Simon Knight)
    • Delphi VersionInfo errors August 18, 2017
      Over the last year or so, we have seen more and more "bug reports" about compiling Delphi projects with FinalBuilder, in particular, reporting issues with compiling version info resources when using Delphi 10.1 (Berlin) and Delphi 10.2 (Tokyo). This only happens if you tell the Delphi action in ...
      VSoft Technologies
    • The Testers Career Path August 16, 2017
      This is a guest posting by Justin Rohrman. Justin has been a professional software tester in various capacities since 2005. In his current role, Justin is a consulting software tester and writer working with Excelon Development. Outside of work, he is currently serving on the Association For ...
      blog.gurock.com (Simon Knight)
    • When Do I Stop Testing? August 16, 2017
      Most of the software projects I have worked on come along with either a specification or a set of acceptance criteria. To the product owner, this is a list of what to build. To me, it also looks like a list of test ideas. A tester can take each point in the specification, or each line item in the ...
      blog.gurock.com (Simon Knight)
    • Strategies for Cross-Platform Code Sharing with Elements August 16, 2017
      Customers ask me for advise for how to best structure their "cross-platform" projects with Elements, all the time. So with this post, I'd like to summarize some experiences and best practices from cross-platform and multi-platform projects I have worked on myself over the past year or two. Not all ...
      RemObjects Blogs (marc hoffman)
    • Workaround for FMX Memory Leaks on Windows in 10.2.1 August 16, 2017
      Many of our customers today write FireMonkey Windows applications. We recently got some customer reports on FMX memory leaks on Windows using RAD Studio 10.2 Release 1 (or Tokyo Release 1). The issue is reported at https://quality.embarcadero.com/browse/RSP-18774 and ...
      Marco's Tech Blog (marcocantu)
    • Debugger Callstack Resolver released August 15, 2017
      Debugger Callstack Resolver is a Delphi IDE plugin that I wrote in 2011 to make the IDE’s CPU View more readable. It colors different instructions, resolves absolute and memory address jump and call targets and shows their function name if available. It also uses the *.jdbg to show more information ...
      Andy's Blog (Andreas Hausladen)
    • Some links on Belise/Elise licensing server (yes, AppWave is dead or at least: should be) August 15, 2017
      Some links on the Embarcadero License Center server (formerly known as Belise and Elise) from my contributions to these G+ threads: Anyone here ever start out using Workstation licenses then switch to eitherNetworked Named User or Networked Concurrent ?… [WayBack] Does anyone know what is happening ...
      The Wiert Corner (jpluimers)
    • Why I Keep Choosing Delphi August 14, 2017
      Early on I learned Turbo Pascal, which was a huge step up from the Basic and Batch File programming I cut my teeth on. When Delphi came along I thought it was brilliant and fell in love immediately. I had no interest in learning other programming languages or tools. Delphi did it all, and that was ...
      The PodCast at Delphi.org (Jim McKeeth)

Always double-check your itinerary

Posted by chuckbeasley on May 19, 2009

I spent the last few days attending a conference in San Francisco.  The conference was Friday through Sunday.  I knew when I purchased my airline ticket the dates of the conference.  Imagine my surprise when I received an email, shortly after midnight Saturday morning, informing me that it was time to check-in for my flight.  I knew this couldn’t be correct because my flight wasn’t scheduled to leave until 12:35 a.m. May 18 or so I thought.  After a conversation with the airline’s customer service department, just before 1 a.m., I realized that I had purchased the ticket for the wrong date.  Now, I’m not going to sit here and blame the website or anything else.  I bought the ticket and failed to verify the date of the return trip.  So, learn from me to always double-check your itinerary before you click the purchase button.  Otherwise, have fun booking a one-way ticket back home!

Posted in Travel | Leave a Comment »

Using OAUTH for Delphi

Posted by chuckbeasley on April 29, 2009

Before attempting to use OAUTH, you must obtain a developer key and secret from the service provider.  In the sample code provided in this article, I have removed my developer key and secret.  No other code modifications have been made.

Step 1 – Request request token (step A in diagram)

procedure TForm1.RqsBtnClick(Sender: TObject);
var
URL: string;
endpos: integer;
begin
Key := ‘http://www.myspace.com/developerkey’;
Secret := ‘developersecret’;
URL := ‘http://api.myspace.com/request_token’;
// Create all objects
Consumer := TOAuthConsumer.Create(Key, Secret);
HMAC := TOAuthSignatureMethod_HMAC_SHA1.Create;

ARequest := TOAuthRequest.Create(URL);

ARequest := ARequest.FromConsumerAndToken(Consumer, nil, URL);
ARequest.Sign_Request(HMAC, Consumer, nil);
HTTPStream := TStringStream.Create(”);
URL := URL + ‘?’ + ARequest.GetString;
Response := idHTTP1.Get(URL);

endpos := AnsiPos(‘&oauth_token_secret=’, Response);
oauth_token := ”;
oauth_token := Copy(Response, 13, endpos-13);
Response := Copy(Response, endpos, Length(Response));

oauth_token_secret := Copy(Response, 21, Length(Response));
Token := TOAuthToken.Create(oauth_token, oauth_token_secret);
end;

The service provider responds by sending a token and token secret, which is parsed from the Response variable.

Step 2 – Authorize (Step C in diagram)

procedure TForm1.AuthBtnClick(Sender: TObject);
var
Callback_URL, URL :string;
begin
URL := ‘http://api.myspace.com/authorize’;
Callback_URL := ‘http://www.chuckbeasley.com’;
URL := URL + ‘?’ + ‘oauth_token=’ + oauth_token + ‘&’ + ‘oauth_token_secret=’ + oauth_token_secret +
‘&oauth_callback=’ + TOAuthUtil.urlEncodeRFC3986(Callback_URL);
EmbeddedWB1.Navigate(URL);
end;

The token, token secret, and call back URL are appended to the URL.  The service provider obtains user authorization and directs the consumer to the call back URL.

Step 3 – Request access token (Step E in diagram)

procedure TForm1.AccBtnClick(Sender: TObject);
var
endpos: integer;
URL: string;
begin
URL := ‘http://api.myspace.com/access_token’;
Consumer := nil;
Consumer := TOAuthConsumer.Create(Key, Secret, ‘http://www.chuckbeasley.com’);
ARequest.HTTPURL := URL;
ARequest := ARequest.FromConsumerAndToken(Consumer, Token, URL);
ARequest.Sign_Request(HMAC, Consumer, Token);
URL := URL + ‘?’ + ARequest.GetString;
Response := idHTTP1.Get(URL);
endpos := AnsiPos(‘&oauth_token_secret=’, Response);
oauth_token := ”;
oauth_token := Copy(Response, 13, endpos-13);
Response := Copy(Response, endpos, Length(Response));

oauth_token_secret := Copy(Response, 21, Length(Response));
Token := TOAuthToken.Create(oauth_token, oauth_token_secret);
end;

The service provider responds by sending an access token and token secret, which is parsed from the Response variable.

Step 4 – Access protected resources (Step G on diagram)

procedure TForm1.AccRscClick(Sender: TObject);

procedure process(o: ISuperObject);
var
f: TSuperObjectIter;
i: Integer;
begin
case ObjectGetType(o) of
stObject:
begin
Memo1.Lines.Add(‘{‘);
if ObjectFindFirst(o, f) then
repeat
keypair := f.key;
process(f.val)
until not ObjectFindNext(f);
ObjectFindClose(f);
Memo1.Lines.Add(‘}’);
end;
stArray:
begin
Memo1.Lines.Add(‘[‘);
for i := 0 to o.AsArray.Length – 1 do
process(o.AsArray.O[i]);
Memo1.Lines.Add(‘]’);
end;
stString:
begin
keypair := keypair + ‘:’ +(UTF8Decode(o.AsString));
Memo1.Lines.Add(keypair);
end;
stNull:
Memo1.Lines.add(‘nil’);
else
Memo1.Lines.add(o.AsString);
end;
end;
var
json: ISuperObject;
StringList: TStringList;
URL: string;
begin
URL := ‘http://api.myspace.com/v2/people/40250975/@friends?count=10000&format=json’;
Consumer := nil;
Consumer := TOAuthConsumer.Create(Key, Secret, ‘http://www.chuckbeasley.com’);
ARequest.HTTPURL := URL;
ARequest := ARequest.FromConsumerAndToken(Consumer, Token, URL);
ARequest.Sign_Request(HMAC, Consumer, Token);
URL := URL + ‘&’ + ARequest.GetString;
Response := idHTTP1.Get(URL);

StringList := TStringList.Create;
StringList.Add(Response);

json := TSuperObject.Create(stObject);
json.Merge(Response);
json := json.O[‘entry’];
Memo1.Lines.Clear;
process(json);
end;

This step assumes that the profile owner has authorized the application to access its protected data.  That can be performed by adding the application to the profile.

OAUTH for Delphi is available via SVN:   http://oauthdelphi.svn.sourceforge.net/.

Posted in Delphi | 2 Comments »

Catching up with technology

Posted by chuckbeasley on March 25, 2009

So, I’ve finally decided to write an entry in my blog.  In less than 2 weeks, I’ve join Twitter and begun blogging.  I’m not exactly sure what I’ll find to write about, but I’ll make it interesting.  Check back from time to time to see what things I find on the ‘net.

Posted in Uncategorized | Leave a Comment »