Thread View: pl.comp.lang.delphi
3 messages
3 total messages
Started by mmm
Wed, 07 Jun 2017 13:26
Youtube Api
Author: mmm
Date: Wed, 07 Jun 2017 13:26
Date: Wed, 07 Jun 2017 13:26
20 lines
1539 bytes
1539 bytes
Webowe rzeczy zupełnie nie moja dziedzina a chciałbym zrobić prosta kontrole rodzicielską :D Ktoś mi podpowie w jaki sposób "wydłubywać" dane z YOUTUBE ? Potrzebuję wszystkie "ID filmów" z danej playlisty? Znalazłem API: https://developers.google.com/youtube/v3/docs/playlistItems/list I przykład użycia w postaci GET https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.playlistItems.list?part=contentDetails%252Cid&maxResults=50&playlistId=PLBCF2DAC6FFB574DE&_h=12& Ale jak to powinno być implementowane po stronie Delphi ? Sa zaimplementowane jakieś klasy dla API Delphi ? Czy trzeba to wszystko zrobić ręcznie za pomocą TRESTClient ? Poproszę o podpowiedz jak korzystać z API Googla w aplikacji delphi Mmm
Re: Youtube Api
Author: Roman Tyczka
Date: Wed, 07 Jun 2017 14:07
Date: Wed, 07 Jun 2017 14:07
13 lines
1147 bytes
1147 bytes
On Wed, 7 Jun 2017 15:26:07 +0200, mmm wrote: > Sa zaimplementowane jakieś klasy dla API Delphi ? > Czy trzeba to wszystko zrobić ręcznie za pomocą TRESTClient ? > > Poproszę o podpowiedz jak korzystać z API Googla w aplikacji delphi Za darmo - rzeźba za pomocą RESTa jak piszesz. Za kasę - https://www.tmssoftware.com/site/cloudpack.asp -- pozdrawiam Roman Tyczka
Re: Youtube Api
Author: m
Date: Wed, 07 Jun 2017 21:24
Date: Wed, 07 Jun 2017 21:24
84 lines
3197 bytes
3197 bytes
W dniu 2017-06-07 o 16:07, Roman Tyczka pisze:
> On Wed, 7 Jun 2017 15:26:07 +0200, mmm wrote:
>
>> Sa zaimplementowane jakieś klasy dla API Delphi ?
>> Czy trzeba to wszystko zrobić ręcznie za pomocą TRESTClient ?
>>
>> Poproszę o podpowiedz jak korzystać z API Googla w aplikacji delphi
>
> Za darmo - rzeźba za pomocą RESTa jak piszesz.
Struganie ręczne to mniej wiecej tak jak poniżej
(jObject.Get('kind').JSONValue.Value ) czy tez można zrobic to jakoś
lepiej ? Jak taki obiekt w Json przenieść do klasy dziedziczącej po
TObject ewentualnie na podstawie RTTI jakies automatyczne przenoszenie
danych ?
uses REST.Client, System.JSON
procedure TForm4.Button2Click(Sender: TObject);
var
RESTClient: TRESTClient;
RESTRequest: TRESTRequest;
RESTResponse: TRESTResponse;
var
jAll: TJSONValue;
jItems:TJSonValue;
jObject: TJSonObject;
begin
RESTResponse := TRESTResponse.Create(self);;
RESTClient := TRESTClient.Create(self);
RESTRequest := TRESTRequest.Create(self);
try
RESTClient.BaseURL :=
'https://www.googleapis.com/youtube/v3/playlistItems';
with RESTClient.Params.AddItem() do
begin
name := 'part';
Value := 'contentDetails,id';
end;
with RESTClient.Params.AddItem() do
begin
name := 'maxResults';
Value := '50';
end;
with RESTClient.Params.AddItem() do
begin
name := 'playlistId';
Value := 'PLBCF2DAC6FFB574DE';
end;
with RESTClient.Params.AddItem() do
begin
name := 'key';
Value := 'AIzaSyCgB1DcSAG7_bSbKn9z_9Y7HM6jhefN-eQ';
end;
RESTRequest.Client := RESTClient;
RESTRequest.Response := RESTResponse;
RESTResponse.RootElement := 'items';
RESTRequest.Execute;
if RESTResponse.StatusCode = 200 then
begin
showmessage(RESTResponse.Content);
jAll := RESTResponse.JSONValue;
if (jAll is TJSONArray) then
begin
jObject := (jAll as TJSONArray).Items[0] as TJSonObject;
showmessage(jObject.Get('kind').JSONValue.Value);
end;
end;
finally
RESTResponse.Free;
RESTClient.Free;
RESTRequest.Free;
end;
end;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads