亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2476 | 回復(fù): 4
打印 上一主題 下一主題

curl老出錯.服務(wù)器端的確收到了客戶端發(fā)過來的信息,但是客戶觀確收不到. [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2008-11-03 17:03 |只看該作者 |倒序瀏覽
class CurlPRC_Class
{
    var $ch; // curl handle

    function CurlPRC_Class()
    {
        $this->ch = null;
        $this->ch = CurlPRC_Class::create();
        return true;
    }

    function __destruct()
    {
        if ($this->ch != null)
        {
            curl_close($this->ch);
            $this->ch = null;
        }
        return true;
    }
    function create()   // init handle
    {
        $ch = null;
        if (!function_exists('curl_init'))
        {
            return false;
        }
        $ch = curl_init();
        if (!is_resource($ch))
        {
            return false;
        }
        return $ch;
    }

    function call($url, $data)  // rpc call
    {
        if (!is_array($data)) return false;

        $post_args = json_encode($data);
         // set
        curl_setopt($this->ch, CURLOPT_TIMEOUT, 3);
        curl_setopt($this->ch, CURLOPT_URL, $url);
        curl_setopt($this->ch, CURLOPT_HEADER, false);
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->ch, CURLOPT_FORBID_REUSE, false);
        // curl_setopt($ch, CURLOPT_PROXY, "192.168.1.1");
        // curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
        curl_setopt($this->ch, CURLOPT_POST, 1);
        curl_setopt($this->ch, CURLOPT_POSTFIELDS, "post=$post_args");

        // call
        echo "........1B\n";
        $post_ret = curl_exec($this->ch);
        echo "........2B\n";

        if (curl_errno($this->ch))
        {
            return false;
        }

        $call_ret = json_decode($post_ret, true);
        if ($call_ret['return'] == "true")
        {
            return $call_ret;
        }
        return false;
    }
}



<?php
    $rpc = new CurlPRC_Class();

     $update_addr = "http://192.168.0.10/rpc_update.php";

    $post_data = array();
    $post_data["devid"]='SO6J0K7K';
  
    echo "........1A\n";
    $ret = $rpc->call($update_addr, $post_data);
    echo "........2A\n";
    if ($ret == false)
    {
        echo "rpc call error <br>\n";
        exit;
    }

?>

誰幫看看哪出錯了,
老出現(xiàn)rpc call error
但是服務(wù)器端的確收到了客戶端發(fā)過來的信息,我已試驗過)

論壇徽章:
0
2 [報告]
發(fā)表于 2008-11-03 17:41 |只看該作者
if ($call_ret['return'] == "true")
        {
            return $call_ret;
        }

改成這樣的:
if ($call_ret['return'] == true)
        {
            return $call_ret;
        }

論壇徽章:
0
3 [報告]
發(fā)表于 2008-11-03 19:07 |只看該作者
還是出錯.

論壇徽章:
0
4 [報告]
發(fā)表于 2008-11-03 21:08 |只看該作者

回復(fù) #3 greenbox 的帖子

我想問一下你這里的$call_ret['return']  有值嗎?你先看看$call_ret 里面的值

論壇徽章:
0
5 [報告]
發(fā)表于 2008-11-06 16:27 |只看該作者

  1. call里面改了,
  2. 發(fā)送時不用json code,就行了,但是接收時用json code就行,不太明白

  3.   function call($url, $data)  // rpc call
  4.     {
  5.         if (!is_array($data)) return false;

  6.         $post_args = json_encode($data);
  7.         echo "url:$url\n";

  8.         //curl_setopt($this->ch, CURLOPT_FORBID_REUSE, false);
  9.         //curl_setopt($this->ch, CURLOPT_TIMEOUT, 3);
  10.         //curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
  11.         curl_setopt($this->ch, CURLOPT_URL, $url);
  12.         curl_setopt($this->ch, CURLOPT_HEADER, false);
  13.         curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
  14.         curl_setopt($this->ch, CURLOPT_POST, 1);
  15.         curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);

  16.         // call
  17.         $post_ret = curl_exec($this->ch);
  18.         $errno = curl_errno($this->ch);
  19.         if ($errno)
  20.         {
  21.             echo "call errno:$errno\n";
  22.             return false;
  23.         }
  24.         $call_ret = json_decode($post_ret, true);
  25.         if ($call_ret['return'] == "true")
  26.         {
  27.             echo "\n\n=============res =============\n $post_ret\n==========================\n\n";
  28.             return $call_ret;
  29.         }
  30.         return false;
  31.     }
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP