Curl returns true instead of value

前端 未结 2 1742
梦毁少年i
梦毁少年i 2020-12-20 15:52

I\'m trying to make a simple API. However, not sure why but I\'m getting true instead of the value that should be returned.

Here\'s the curl code.

tr         


        
2条回答
  •  猫巷女王i
    2020-12-20 16:38

    You need to echo not return:

    echo $_POST['auth_token'];
    

    And you need CURLOPT_RETURNTRANSFER to have curl_exec() return the content:

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    

    curl_exec

    Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.

提交回复
热议问题