Wp_remote_post là gì?


Bạn đang chuyển thông số yêu cầu không chính xác

Hãy xem trang Codex. Bạn có thể tìm thấy ví dụ như vậy trong đó

$response = wp_remote_post[ $url, array[
  'method' => 'POST',
  imeout' => 45,
  'redirection' => 5,
  'httpversion' => '1.0',
  'blocking' => true,
  'headers' => array[],
  'body' => array[ 'username' => 'bob', 'password' => '1234xyz' ],
  'cookies' => array[]
   ]
];

Vì vậy, trong trường hợp của bạn, nó sẽ trông giống như thế này

$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];


trình bày bởi. Wordpress/Stackoverflow

Trong bài viết trước, chúng tôi đã xem xét các bài viết trước về yêu cầu GET, cơ sở PHP gốc để tạo yêu cầu và xem xét chức năng API WordPress

3
09 cùng với các đối số mà nó cung cấp

Trong bài viết này, chúng tôi sẽ sử dụng

3
09 để chúng tôi thực sự có thể thấy nó hoạt động. Hãy nhớ rằng điều này - chẳng hạn như
3
09 - là một phần của API HTTP trong đó có các chức năng khác đáng xem xét

Tuy nhiên, hiện tại, chúng tôi sẽ đưa

3
09 vào hoạt động

Cụ thể chúng ta sẽ làm như sau

  • Khi tải trang, chúng tôi sẽ gửi một số thông tin tới tập lệnh tùy chỉnh
  • Tập lệnh sẽ kiểm tra thông tin và đưa nó trở lại trang của chúng tôi
  • Sau đó chúng tôi sẽ hiển thị dữ liệu trên trang

Chắc chắn, đó là một ví dụ hơi giả tạo nhưng nó sẽ cho chúng ta kinh nghiệm tạo một tập lệnh PHP riêng biệt có thể được sử dụng cho các hoạt động được kích hoạt bằng cách sử dụng

3
09

Dù sao, với mục đích của ví dụ này, chúng tôi sẽ sử dụng bộ sưu tập PHP

3
14 để ghi nhật ký khi người dùng đã gửi tùy chọn của họ thay vì yêu cầu họ phải đăng nhập

Cuối cùng, mã nguồn sẽ được cung cấp trên GitHub và có thể truy cập ở phần cuối của loạt bài này trong bài viết sau

Tuy nhiên, bây giờ, hãy bắt đầu làm việc với plugin

Sắp ra khỏi lớp

Nếu bạn đã theo dõi bất kỳ bài viết nào của tôi trong vài tháng qua, thì bạn biết rằng tôi là người hâm mộ mẫu đơn lẻ và tôi thường sử dụng cùng một bản soạn sẵn để xây dựng các plugin của mình

Cuối cùng, rất nhiều điều này sẽ được lặp đi lặp lại - không sao, bây giờ. Logic nghiệp vụ - hay logic cốt lõi - của plugin là thứ sẽ thay đổi, vì vậy hãy chú ý theo dõi

Chuẩn bị Plugin

Trong thư mục wp-content/plugins của bạn, hãy tạo một thư mục có tên wp-remote-post-example vì đây sẽ là tên của plugin của chúng tôi. Sau đó, tất cả các tệp sau

  • wp-remote-post-ví dụ. php
  • class-wp-remote-post-ví dụ. php
  • wp-remote-receiver. php

Trong wp-remote-post-ví dụ. php, thêm đoạn mã sau

1
2
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
0
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
2
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
4
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
6
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
7
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
00
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
01
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
02
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
03
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
04
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
05
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
06
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
07
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
08
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
09
3
0
3
1
3
2
3
3
3
4
3
5
3
6
3
7
3
8

Sau đó, trong class-wp-remote-post-example. php thêm đoạn mã sau

E

Cuối cùng, thêm dòng sau vào wp-remote-receiver. php

1
_______9
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
0
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
59
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
7
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
62
2
1
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
64
2
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
66
2
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
32
2
7
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
70
2
9
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
01
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
73
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
03
3
8

Lưu ý rằng chúng ta sẽ lặp qua danh sách dữ liệu

3
15 và hiển thị nó ở định dạng danh sách giúp dễ đọc

Lưu ý rằng để tiết kiệm dung lượng, tôi sẽ để lại các nhận xét mã từ plugin cụ thể này. File tải về trên GitHub sẽ được ghi đầy đủ và cũng sẽ có trong bài tiếp theo

Tại thời điểm này, bạn sẽ có thể kích hoạt plugin;

cái này tốt

Nhận thông tin yêu cầu

Tại thời điểm này, hãy thu thập thông tin mà chúng tôi muốn gửi như một phần của yêu cầu. Cụ thể, chúng ta hãy lấy như sau

  • Địa chỉ duy nhất của khách truy cập
  • Địa chỉ trang chủ của blog
  • Địa chỉ của trang đang được truy cập

Thêm dòng sau vào hàm tạo [hàm

3
16 riêng tư, không phải là hàm
3
17 công khai]

___8____9

$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
78

Tiếp theo, thêm chức năng sau vào lớp

1
_______9
2
01
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
3
2
04
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
7
2
07
2
1
2
09
2
3
2
11
2
5
2
7
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
32
2
9
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
01
2
17
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
03
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
04
3
1

Ở đây, chúng tôi đang lấy ID duy nhất từ ​​chỉ mục

3
18 của bộ sưu tập
3
14, chúng tôi đang lấy URL của trang web do WordPress xác định và sau đó chúng tôi lưu trữ permalink của trang hiện tại vào biến riêng của nó

thực hiện yêu cầu

Tại thời điểm này, chúng tôi đã sẵn sàng để thực hiện yêu cầu. Nhớ lại từ bài viết trước rằng có một số thông tin chúng tôi cần gửi cùng với yêu cầu

  • URL
  • Nội dung của nội dung [mà chúng tôi sẽ sử dụng làm ID duy nhất, Địa chỉ và Trang đã xem

Đủ dễ dàng, phải không?

Vì vậy, hãy tiếp tục cập nhật chức năng của chúng tôi ở trên với khối mã sau để chức năng bây giờ trông như thế này

1
2
2
01
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
3
2
04
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
7
2
07
2
1
2
09
2
3
2
11
2
5
2
7
2
36
2
9
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
01
2
39
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
03
2
41
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
04
2
43
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
06
2
45
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
08
2
47
3
0
2
49
3
2
2
51
3
3
2
53
3
5
2
55
3
7
2
57
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
52
2
59
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
32
2
61
2
62
2
17
2
64
2
65
3
1

Tại thời điểm này, bạn sẽ có thể tải lại trang mặc dù bạn không nhất thiết phải thấy bất kỳ điều gì xảy ra

Thậm chí, nó không có gì quá phức tạp, phải không?

Hiển thị kết quả

Tại thời điểm này, giả sử mọi thứ được kết nối chính xác, bây giờ chúng ta có thể hiển thị kết quả

Để làm điều này, trước tiên chúng ta cần kiểm tra xem có lỗi hay không, sau đó hiển thị thông báo nếu có;

Thêm điều kiện sau vào hàm trên ngay dưới lệnh gọi

3
09

1
2
2
69
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
3
2
72
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
5__
2
74
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
7
2
76
2
1
2
3
3
1
2
5
2
81
2
7
2
9
2
84
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
01
2
86
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
03
2
88
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
04
2
76
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
06
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
08
3
1
3
0__6___2

Lưu ý rằng chúng tôi đang chọn nối thêm một số HTML dựa trên phản hồi sẽ hiển thị ở cuối bài đăng

Phiên bản làm việc hiện tại

Tại thời điểm này, phiên bản làm việc hiện tại của plugin sẽ trông như thế này

1
2
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
0
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
23
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
26
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
7
2
1
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
29
2
3
2
5
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
010
2
7
2
9
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
32
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
01
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
03
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
35
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
04
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
06
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
38
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
08
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
40
3
0
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
42
3
2
3
3
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
45
3
5
3
7
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
32
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
52
2
59
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
032
2
61
2
62
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
035
2
64
2
65
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
038
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
039
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
040
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
041
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
042
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
043
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
044
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
045
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
046
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
047
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
048
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
049
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
050
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
051
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
052
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
053
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
054
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
055
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
056
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
057
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
058
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
059
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
060
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
061
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
062
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
063
2
53
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
065
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
066
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
067
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
068
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
069
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
070
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
071
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
072
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
073
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
074
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
075
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
076
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
077
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
078
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
079
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
080
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
081
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
082
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
083
$args = array[
    'method' => 'POST',
    'headers'  => array[
        'Content-type: application/x-www-form-urlencoded'
    ],
    'sslverify' => false,
    'body' => array[
        'api' => get_option['API_key'],
        'gw' => '1'
    ]
];

$api_response = wp_remote_post['//myurl.com/api', $args];
084___

Trong bài đăng tiếp theo và cũng là bài đăng cuối cùng của loạt bài này, chúng tôi sẽ nỗ lực làm cho thông tin được thêm vào cuối bài đăng trông gọn gàng hơn một chút thông qua việc sử dụng LESS cho CSS chỉ để có một số kinh nghiệm về điều đó và để tiếp tục cải thiện

Chúng tôi cũng sẽ đảm bảo rằng plugin được ghi lại đầy đủ và có sẵn trên GitHub để xem xét thêm

Cho đến lúc đó, hãy tìm hiểu những gì chúng tôi đã đề cập ở đây và chúng tôi sẽ có nhiều điều hơn để chia sẻ trong bài viết cuối cùng

Chủ Đề