提交的服务器端:
if(登录成功){
  echo('00');
}else{//失败
  echo('11');
}你这边的程序:
$ch = curl_init();
$url="提交服务服务器地址和参数";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$a=curl_exec($ch);
curl_close($ch);
if($a=='00'){
  成功了执行的代码;
}elseif($a=='11'){
  登录失败
}大体这样吧,不知道是不是你想的那样.

解决方案 »

  1.   


    接收两个参数A和B,当A=00代表登陆成功,取B里的URL跳转。是不是可以直接跳转到别的网址?
      

  2.   

    $arrayData = array("name" => "Hagrid", "age" => "36");
    $sendJsonData = json_encode($arrayData);
    $ch = curl_init('http://127.0.0.1/jietu/test.php');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $sendJsonData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($sendJsonData))
    );
    $ret = curl_exec($ch);
    if($ret == '00'){
      成功了执行的代码;
    }elseif($ret == '11'){
      登录失败
    }
      

  3.   


    这本来是这样的写的,登录失败
    {"aa":"00","bb":"http://www.xxx.com/index"}
    写了半天要不取不到aa要么就取不到bb,只有当aa=00才是登录成功。刚摸索这块
      

  4.   

    var_dump($ret = curl_exec($ch));你输出你的值看看
      

  5.   


    boolean false现在post数据成功,只是返回值{"aa":"00","bb":"http://www.xxx.com/index"}怎么取过来
      

  6.   

    就像版主说的,返回值用json_decode转换下
      

  7.   


    更迷茫能来个例子吗?
    现在我对接口提交数据成功了,怎么取回这个{"aa":"00","bb":"http://www.xxx.com/index"}来点简单易懂了刚摸索
      

  8.   


    boolean false现在post数据成功,只是返回值{"aa":"00","bb":"http://www.xxx.com/index"}怎么取过来
    $json_str = '{"aa":"00","bb":"http://www.xxx.com/index"}';
    $arr = json_decode($json_str);
    print_r($arr);
      

  9.   

    你 $ret = curl_exec($ch) 后
    echo $ret; 得到 {"aa":"00","bb":"http://www.xxx.com/index"}
    表示你确实接收到了一个 json 串
    那么
    $t = json_decode($ret);
    print_r($t);
    /*
    stdClass Object
    (
        [aa] => 00
        [bb] => http://www.xxx.com/index
    )
    */$t = json_decode($ret, 1);
    print_r($t);
    /*
    Array
    (
        [aa] => 00
        [bb] => http://www.xxx.com/index
    )
    */
    你都在用 json 了,怎么连 json 相关的函数都不知道?