R
R
reds2018-01-06 22:50:34
WordPress
reds, 2018-01-06 22:50:34

How to get Api data via Post (PHP)?

I'm just learning programming, I can get api data via file_get_contents or curl, but I want to understand how to work via post, since webmoney does not provide data directly
There is a C # example on the link, but I need it via PHP. I searched Google and substituted my data in different scripts, but everywhere there is a white screen, I can’t even get a single working example to receive data via post, nothing is loaded even without changing the data on the page.
wiki.webmoney.ru/projects/webmoney/wiki/INDX_API_HistoryTransaction
URL for request transmission – https://secure.indx.ru/api/v1/tradejson.asmx
method – POST
accept types: text/json
request format:
{"Login":"","Wmid":"","Culture":"","Signature":"","Trading":{"ID":0,"DateStart":"","DateEnd" :""}}
Since the login data for the API is required, you can write a script without them, I will check with my data.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Brumer, 2019-10-26
@MRcracker

something like this:
added 2 parameters posts_per_page and paged at the very beginning

$args = array(
  'posts_per_page' => 4,//сколько записей на одной странице?
  'paged'    => (get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1),//текущий номер страницы
  'numberposts'      => 10,
  'offset'           => 0,
  'category'         => 0,
  'orderby'          => 'post_date',
  'order'            => 'DESC',
  'include'          => '',
  'exclude'          => '',
  'meta_key'         => '',
  'meta_value'       => '',
  'post_type'        => 'post',
  'post_status'      => 'draft, publish, future, pending, private',
  'suppress_filters' => true,
); 

$result = wp_get_recent_posts( $args );
foreach( $result as $post ){
  setup_postdata( $post );
  the_title(); // вывод
}
wp_reset_postdata();
//добавляем либо свою пагинацию,
//либо the_posts_pagination();
//либо the_posts_navigation();
//либо echo paginate_links();

you can define options for paginate_links():
$param=array(
  'base'               => '%_%',
  'format'             => '?paged=%#%',
  'total'              => 5,
  'current'            => 2,
  'show_all'           => false,
  'end_size'           => 1,
  'mid_size'           => 2,
  'prev_next'          => true,
  'prev_text'          => __('« Previous'),
  'next_text'          => __('Next »'),
  'type'               => 'plain',
  'add_args'           => false,
  'add_fragment'       => '',
  'before_page_number' => '',
  'after_page_number'  => ''
);
echo paginate_links($param);

D
Decadal, 2018-01-06
@Decadal

POST is the request method. If you know how to curl - you know how to make POST requests. If not, read about Curl or Guzzle . These are the same utilities and libraries that allow the server to make a request to another server (including using the POST method).

N
nozzy, 2018-01-06
@nozzy

curl can also send data via POST
curl_setopt($ch, CURLOPT_POST, 1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question