显示登录的way2sms PHP脚本失败

显示登录的way2sms PHP脚本失败,php,way2sms,Php,Way2sms,您好,我正在尝试使用way2sms PHP脚本,我使用了以下代码,但它显示登录失败的所有时间,虽然我给正确的id密码,请帮助 提前谢谢 <?php $obj=new way2sms('id','password'); $result=$obj->sendSMS('receivernumber','messege'); echo implode('<br >',$result); /*way2sms *used to send sms using web serv

您好,我正在尝试使用way2sms PHP脚本,我使用了以下代码,但它显示登录失败的所有时间,虽然我给正确的id密码,请帮助

提前谢谢

    <?php
$obj=new way2sms('id','password');
$result=$obj->sendSMS('receivernumber','messege');
echo implode('<br >',$result);
/*way2sms
 *used to send sms using web service
 *@ $uid       String:  username to authenticate the way2sms website
 *@ $pwd       String:  password for way2sms website
 *@ $phone     String:  phone numbers of recipients
 *@ $msg       String:  the message to be send
 */
class way2sms
{
    var $uid,$pwd,$phone,$msg;
    /*
    *@ constructor of way2sms class
    *
    *@ $id     String :  username to authenticate the way2sms website
    *@ $pass   String :  password for way2sms website
    *
    */
    function way2sms($id,$pass)
    {
        $this->uid=urlencode($id);
        $this->pwd=urlencode($pass);
    }
    /*
    *sendSMSToMany
    *@description : to send the sms
    *
    *@ $phone    String :  phone numbers of recipients
    *@ $msg      String :  the message to be send
    *
    *@return     array :  error message or success message
    */

    function sendsms($phone, $msg)
    {
        $curl = curl_init();
        $timeout = 30;
        $result = array();
        $autobalancer=rand(1,8);

        curl_setopt ($curl, CURLOPT_URL, "http://site".$autobalancer.".way2sms.com/Login1.action");
        curl_setopt ($curl, CURLOPT_POST, 1);
        curl_setopt ($curl, CURLOPT_POSTFIELDS, "username=" . $this->uid . "&password=" . $this->pwd);
        curl_setopt ($curl, CURLOPT_COOKIESESSION, 1);
        curl_setopt ($curl, CURLOPT_COOKIEFILE, "cookie_way2sms");
        curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt ($curl, CURLOPT_MAXREDIRS, 20);
        curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
        curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt ($curl, CURLOPT_REFERER, "http://site".$autobalancer.".way2sms.com/");
        $text = curl_exec($curl);
        preg_match_all('/<input[\s]*type="hidden"[\s]*name="Token"[\s]*id="Token"[\s]*value="?([^>]*)?"/si', $text, $match);
        $token = $match[1][0]; 



        // Check for proper login
        $pos = stripos(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), "main.action");

        if ($pos === "FALSE" || $pos == 0 || $pos == "") return array("Login Failed");

        if (trim($msg) == "" || strlen($msg) == 0) return array("Invalid message");

        $msgs = $this->split_for_sms($msg);

        //$pharr = explode(",",$phone);
        $p=$phone;
        $refurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
        $refurl_instantsms=0;
        // foreach ($pharr as $p)
        // {
            if (strlen($p) != 10 || !is_numeric($p) || strpos($p, ".") != false)
            {
                array_push($result,"Invalid number : " . $p . ". ");
                //continue;
            }
            foreach($msgs as $msg)
            {
                curl_setopt ($curl, CURLOPT_REFERER, $refurl);
                curl_setopt ($curl, CURLOPT_URL, "http://site".$autobalancer.".way2sms.com/jsp/SingleSMS.jsp?Token=".$token);
                $text = curl_exec($curl);

                preg_match_all('/rqMob=["\']([\d\w]+)["\'];/si', $text, $match);
                $rqMob=$match[1][0];
                preg_match_all('/rqTok=["\']([\d\w]+)["\'];/si', $text, $match);
                $rqTok=$match[1][0];
                //preg_match_all('/tkn=["\']?([\d\w\W]+)?["\'];/si', $text, $match);
                $Token=$token;
                /* preg_match_all('/<input[\s]*type="hidden"[\s]*name="cgnr"[\s]*id="cgnr"[\s]*value="?([^>]*)?"/si', $text, $match);
                $cgnr=$match[1][0];
                preg_match_all('/<input[\s]*type="hidden"[\s]*name="wasup"[\s]*id="wasup"[\s]*value="?([^>]*)?"/si', $text, $match); */
                preg_match_all('/[\s]*name=["\']wasup["\'][\s]*id=["\']wasup["\'][\s]*value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/name=["\']wasup["\'][\s]*id=["\']wasup["\'][\s]*><option value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/[\s]*name=["\']wasup["\'][\s]*id=["\']wasup["\'][\s]*>?([^>]*)?</si', $text, $match);
                $wasup=$match[1][0];

                preg_match_all('/[\s]*name=["\']nrc["\'][\s]*id=["\']nrc["\'][\s]*value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/name=["\']nrc["\'][\s]*id=["\']nrc["\'][\s]*><option value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/[\s]*name=["\']nrc["\'][\s]*id=["\']nrc["\'][\s]*>?([^>]*)?</si', $text, $match);
                $nrc=$match[1][0];
                preg_match_all('/[\s]*name=["\']HiddenAction["\'][\s]*value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/name=["\']HiddenAction["\'].*><option value=["\']?([^>]*)?["\']/si', $text, $match);
                $HiddenAction=$match[1][0];
                preg_match_all('/[\s]*name=["\']hud_pani["\'][\s]*id=["\']hud_pani["\'][\s]*value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/name=["\']hud_pani["\'][\s]*id=["\']hud_pani["\'][\s]*><option value=["\']?([^>]*)?["\']/si', $text, $match);
                if(!isset($match[1][0]))
                    preg_match_all('/[\s]*name=["\']hud_pani["\'].*id=["\']hud_pani["\'][\s]*>?([^>]*)?</si', $text, $match);
                $hud_pani=$match[1][0];

                preg_match_all('/[\s]*name=["\']catnamedis["\'][\s]*id=["\']catnamedis["\'][\s]*value=["\']?([^>]*)?["\']/si', $text, $match);
                $catnamedis = $match[1][0];
                preg_match_all('/[\s]*id=["\']diffNo["\'][\s]*name=["\']diffNo["\'][\s]*value=["\']?([^>]*)?["\']/si', $text, $match);
                $diffNo = $match[1][0];

                /* preg_match_all('/<select[\s]*style="display: none;"[\s]*name="action"[\s]*id="action%>"[\s]*><option[\s]*value="?([^>]*)?"/si', $text, $match);
                $action = $match[1][0]; // get custid from the form fro the Action field in the post form                
                preg_match_all('/<textarea[\s]*style="display: none;"[\s]*name="Token"[\s]*id="Token">?([^>]*)?<\/textarea>/si', $text, $match);
                $Token = $match[1][0]; */

                $p = urlencode($p);

                if($refurl_instantsms == 0)
                {
                    $refurl_instantsms=curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
                }

            // Send SMS

                curl_setopt ($curl, CURLOPT_URL, "http://site".$autobalancer.".way2sms.com/jsp/stp2p.action");
                curl_setopt ($curl, CURLOPT_REFERER, $refurl_instantsms);
                curl_setopt ($curl, CURLOPT_POST, 1);

                curl_setopt ($curl, CURLOPT_POSTFIELDS, "nrc=$nrc&wasup=$wasup&HiddenAction=$HiddenAction&hud_pani=$hud_pani&catnamedis=$catnamedis&$rqTok=$Token&$rqMob=$p&textArea=$msg&diffNo=$diffNo");
                curl_exec($curl);
                //var_dump(curl_getinfo($curl));
                @$sendError .= curl_error($curl);
            }
            array_push($result,"Message Sucessfully send to : " . $p . ". ");
        //}

        // Logout
        curl_setopt ($curl, CURLOPT_URL, "http://site".$autobalancer.".way2sms.com/jsp/logout.jsp");
        curl_setopt ($curl, CURLOPT_REFERER, $refurl);
        $text = curl_exec($curl);    

        curl_close($curl);
        if (!empty($sendError)){
            return array($sendError);
        }
        return $result;
    }
    function split_for_sms($msg)
    {
        $length=strlen($msg);
        if($length <= 160)
        {
            return array(urlencode($msg));
        }
        else
        {
            preg_match_all("~.{0,153}(\s|$)~",$msg,$matches);
            $matches=array_filter($matches[0]);
            foreach($matches as $key=>$match)
                $matches[$key]=urlencode("PART-".($key+1).":".$matches[$key]);
            return $matches;
        }
    }
}


?>


我应该做些什么来克服这个问题?

什么是
var\u dump($text)给予?不知道它在做什么。没有错误,只是无法登录way2sms并显示登录失败@尚卡达莫达兰