0

I'm sorry, I speak a little English.

I read it all here. Why not works? No post data.

Edited (with Content-type):

$postdata = http_build_query( array(

    'request'=> 'activate',
    'license-key'=> $_POST [ 'license-key' ],
    'http_host'=> $_SERVER [ 'HTTP_HOST' ],
    'wp_version'=> $wp_version,
    'theme_version'=> $theme_version

) );

$opts = array( 'http'=> array(

    'method'=> 'POST',
    'header'=> 'Content-type: application/x-www-form-urlencoded',
    'content'=> $postdata

) );

$context = stream_context_create( $opts );

$json = file_get_contents( 'https://test2.com/api', false, $context ); // https://test2.com/api/index.php

https://test2.com/api

$postdata = json_encode( $_POST );
$sql = "INSERT INTO `api`( `request`, `postdata`, `return` ) VALUES( '" . $_POST [ 'request' ] . "', '" . $postdata . "', 'success' )";

The database:

INSERT INTO `api`( `request`, `postdata`, `return` ) VALUES( '', '[]', 'success' );

Why empty the request and postdata columns? The return column is okay.

error_log

[28-Jul-2021 16:25:12 America/New_York] PHP Notice:  Undefined index: request in /home/*/public_html/api/index.php on line 15

The 14-15. line:

$postdata = json_encode( $_POST );
$sql = "INSERT INTO `api`( `request`, `postdata`, `return` ) VALUES( '" . $_POST [ 'request' ] . "', '" . $postdata . "', 'success' )";

Log:

162.0.235.*** - - [28/Jul/2021:16:01:09 -0400] "POST /api HTTP/1.0" 301 707 "-" "-"
162.0.235.*** - - [28/Jul/2021:16:01:09 -0400] "GET /api/ HTTP/1.0" 200 20 "-" "-"
162.0.235.*** - - [28/Jul/2021:16:03:38 -0400] "POST /api HTTP/1.0" 301 707 "-" "-"
162.0.235.*** - - [28/Jul/2021:16:03:38 -0400] "GET /api/ HTTP/1.0" 200 20 "-" "-"
162.0.235.*** - - [28/Jul/2021:16:07:07 -0400] "POST /api HTTP/1.0" 301 707 "-" "-"
162.0.235.*** - - [28/Jul/2021:16:07:07 -0400] "GET /api/ HTTP/1.0" 200 20 "-" "-"

Please help me.

jozs2021
  • 91
  • 7

0 Answers0