PHP中jquery对象的等价物是什么


What is the equivalent of jquery object in PHP?

下面的jquery函数是来自boomerang的一个示例脚本。这是他们的GetSendList函数。我试图制作它的php版本,但仍然没有成功。功能如下:
function GetSendList() {
    var r = new Object;
    r = [
        {
            email: $("#txt-SendList-email-0").val(),
            jobNumber: $("#txt-SendList-jobNumber-0").val()
        },
        {
            email: $("#txt-SendList-email-1").val(),
            jobNumber: $("#txt-SendList-jobNumber-1").val()
        }
    ]

    var dataString = JSON.stringify(r);
    $.ajax({
        type: "POST",
        url: "https://target.boomerang.com/V1.0/api/SendList",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        data: dataString,
        headers: { auth_token: $('#txtAuthenticationCode').val() },
        success: function (response) {
        }
    });
}

这是我的PHP脚本:

$main_url = "https://target.boomerang.com/V1.0/api/";
$token = "xxx";
$values = array('email'=>'email',
    'jobNumber'=>'jobnumber'
    );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$main_url."SendList");
curl_setopt($ch,CURLOPT_HTTPHEADER,array('auth_token: '.$token));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($values));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
$output = json_decode($server_output);

我猜我的值格式不对,这就是我失败的原因。我不知道jquery对象在PHP中的等价性。

PS。我使用相同的php脚本来调用它们的其他函数,并且我成功地使用了这些函数。我现在遇到问题的只是GetSendList。请提供建议。谢谢

要在PHP上创建一个对象,只需要执行以下操作:

$object = (object) array(); // Or new stdClass();

用途:

$object->name = "John";
echo $object->name;

与Javascript一起使用:

$object = json_decode( $_POST['json'] );
$json = json_encode( $object );