Usability Upgrades to This Blog

In recent days, I have spent a significant amount of time making this blog better to use. First, I wanted to make sure that English speakers had the option to browse English posts only; obviously, I wanted the same for the German speakers. Consequently, the menu bar offers sub-menu items to browse English and German articles separately.

Furthermore, blog posts with certain topics can be easier accessed: According to my site stats, 5-Minute-Snacks are one of people’s favorites. A sub-menu item gives a list of those only.

Finally, anything that has to do with Embarcadero MVP activities, like conferences, seminars, or other trainings, can be found in the “Embarcadero MVP” listing. 

Visual improvements have also been made. I got rid of unnecessary sidebars, footers etc. Furtmermore, the font has been changed to a clear, sharp Google web font. 

I hope you like the improvements. As always, your feedback is always welcome.


5-Minute-Snack: Reading Twitter Feeds in a Delphi VCL app

After a long time, a new 5-Minute-Snack for Delphi desktop application developers that still love the VCL as much as I do… (I can also tell you about one thing that I 100% dislike: the new WordPress editor aka Gutenberg. What a mess! I am a developer, so please let me type my post and be done with it. These new blocks are ridiculous.)

Actually, I have to confess that you will need the fabulous TMS VCL Cloud Pack to reproduce this snack. Even though Delphi is an amazing tool, it would take you longer than 5 minutes to write an interface to the Twitter API.

So, without further ado, let’s look at the GUI we are going to use to access Twitter. We need two buttons:

  • one to connect to Twitter and authenticate access to your account and
  • another button that actually retrieves the tweets.

We are going to dump all the tweets into a TMemo control:

Finally, we need to drop the TAdvTwitter control from the TMS VCL Cloud Pack. This component will provide methods to read tweets from any Twitter account. However, you will also need a Twitter account yourself and you will have to create a developer account. The steps for this are described here:

After being provided with a key and a secret, add them to the App property in the Object Inspector of the TAdvTwitter control, which I named Twitter. Another option is to set these properties in code if you want to retrieve the information from a database etc.

Let’s look at the code to connect to Twitter and I’ll elaborate a bit more on the tricky parts:

The Twitter API expects you to enter you username and password when you want to access it. This has to be done manually. Thus, when you connect for the first time, a browser window will open and you will be presented with the Twitter login dialog. In case you password is correct, you will be handed a token from the API that will allow you continuous access without entering the information over and over again. Thus, we need to tell our app where to store this info. This example sets up the component to save the tokens in an ini file. 

The code basically loads the tokens from the file. If the file does not exist, the tokens are expired, or you simply use the app for the first time, the call to Twitter.TestToken  will return false. On the other hand, it will return true of the tokens are valid. Furthermore, Twitter.DoAuth will only be called if necessary to bring up the browser window that allows you to enter username and password.

The final step is to call Twitter.Connect . It will return true when connected, false otherwise. We use this to enable or disable the retrieve button, which is disabled by default.

The code to retrieve the tweets could not be any simpler:

We clear the memo and also clear any previously retrieved tweets. Tweets are called “status changes” in the TMS documentation and thus the property to access the tweets is a list of TTwitterStatus .  In order to fill the list with data you invoke Twitter.GetStatuses . The method name is chosen a bit unlucky, as the plural of ‘status’ is also ‘status’, but code-completion will assist us there. You can specify how many tweets you want to retrieve, starting with the most-recent. Then you have different parameters to retrieve tweets by date and numerical user id. I decided to use the Twitter handle to specify the feed I want to retrieve. This could well be another TEdit  control on the form to make it variable. 

After retrieving all the tweets, we simply iterate the list and add the tweets to the memo. 

Above you see the code output showing the last 5 tweets from the President of the United States on March 24th, 2018. 

Try connecting to Twitter a second time after reopening the application. You will not need to provide your credentials again. This shows the token mechanism works properly as well.


Tags: , , , ,

ORM mit Delphi: TMS Aurelius Free Edition

TMS Software hat diese Woche eine kostenlose Version Ihres ORM Werkzeuges ‘TMS Aurelius’ veröffentlicht. Die neue Version unterstützt nun Delphi 10.3 Rio.

Im Gegensatz zu vielen anderen kostenlosen Produkten, hat die kostenlose Version keinerlei Funktionseinschränkungen gegenüber der kostenpflichtigen Version. Selbst die Nutzung innerhalb kommerzieller Anwendungen ist gestattet. Alle Features, die in der kommerziellen Variante enthalten sind, sind auch in der kostenlosen Variante zu finden. 

Die kostenlose Version enthält keinen Quelltext und es wird kein kostenloser Support angeboten. Weiterhin werden keine Versionen für ältere Delphi Versionen angeboten. Da Delphi aber mittlerweile ausschliesslich als Maintenance-Produkt verkauft wird, sollte das keine Hürde zum Einsatz der Software mehr darstellen.

Zum Download der kostenlosen Version ist eine Registrierung erforderlich. Auf der Seite ist auch eine vollständige Auflistung aller Features zu finden. 

Auf einer der letzten CodeRage Veranstaltungen wurde das Produkt im Detail vorgestellt:

Tags: , , ,

Web Services mit Delphi: Tutorial zu TMS XData für Einsteiger

TMS XData ist ein Delphi Framework zur Entwicklung von Multi-Tier Server Anwendungen. Es ist sehr einfach einen REST Webservice mit JSON zu erstellen, der das HTTP bzw. HTTPS Protokoll verwendet. 

Sollte Ihnen diese Beschreibung, bereits Kopfschmerzen bereiten, dann ist die Tutorialserie zu XData genau das richtige für Sie! Die Serie motiviert zunächst erst einmal die Verwendung eines Web Services und erläutert alle Begriffe. Erst dann wird Schritt für Schritt beschrieben, wie Sie eine Serveranwendung erstellen. Nach der Serveranwendung werden Sie lernen, einen Client in der VCL und als Webanwendung mit TMS Web Core zu entwickeln.

Im letzten Teil werden Strategien zur Bereitstellung des Dienstes gegeben. Die Serie bietet Ihnen also ein Rundumpaket zur Entwicklung von Client- und Serveranwendungen mit den neuesten Technologien. Und das allerbeste: Die Serie ist kostenfrei und in deutscher Sprache verfügbar! Viel Spass beim Eintauchen in die Welt von TMS XData!

Teil 1:

Teil 2:

Teil 3:

Teil 4: 

Tags: , , , , , ,