H
H
hunter4freedom2020-05-22 15:38:05
API
hunter4freedom, 2020-05-22 15:38:05

How to embed JSON in WordPress?

Good afternoon! Reply to the user, please. Need to integrate API (JSON) into WordPress site. No matter how hard you try, it doesn't work. Through the plugin "Json Content Importer" nonsense comes out. At the moment this is the code:

procedure TForm1.Button3Click(Sender: TObject);
var
  url, html : String;
begin
  url := 'https://steampay.com/api/products';
  html := TFPCustomHTTPClient.SimpleGet(url);

  memo1.Text := trim(html);
procedure TForm1.Button1Click(Sender: TObject);
var
  J: TJSONData;
  begin
    J:=GetJSON(Memo1.text);  //Место где мы берем данные, в моем случаем это Memo1

    Memo2.Text:=J.FindPath(Edit1.Text).AsString; //Куда копируем результат, и путь до значение которое требуется
    J.Free; //Не забываем освобождать память, иначе будут утечки...
  end;


I understand that this is also dregs. I put it also does not come out ... $getjson url=https://steampay.com/api/products';

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WP Panda, 2020-05-22
@wppanda5

Json is just a data format, a bus that carries your data, work like with a regular object / array.
Drop off the contents of the bus and do what you want

$data = file_get_contents( 'https://steampay.com/api/products' );
  if ( ! empty( $data ) ) {
    $args = json_decode( $data );
    
    foreach ( $args->products as $one_product ) {
      echo $one_product->title . '<br>';
    }
  }

Q
QuestYouCraft, 2020-05-22
@QuestYouCraft

You need to embed JSON in PHP
Or here is another Yandex article on this topic
to help on this issue ..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question