public function addExpress() { ignore_user_abort(0); set_time_limit(0); if ($this->isPost()) { $data['pid'] = $_POST['pid']; $data['message'] = $_POST['message']; $data['is_important'] = $_POST['is_important']; $data['ctime'] = date("Y-m-d H:i:s"); $mod = M('PingPexpress'); $id = $mod->add($data); if ($id) { M("Ping")->where("id='" . $data['pid'] . "'")->save(array('status' => $_POST['status'])); $orders = M("PingOrder")->where("pid='" . $data['pid'] . "'")->group("mobile")->select(); foreach ($orders as $order) { $data['orderid1'] = $order['orderid1']; M("PingExpress")->add($data); if ($data['is_important']) { //发送短信 $sms = new Sms(); $tinyurl = tinyurl($this->baseurl . "?m=Ping&a=myorder&pid=" . $order['pid']); $tinyurl = $tinyurl ? $tinyurl : $this->baseurl . "?m=Ping&a=myorder&pid=" . $order['pid']; $content = $data['message'] . " 查看订单" . $tinyurl . ""; if (preg_match('/\\d{11}/', $order['mobile'])) { $smsresult = $sms->noticeSms($order['mobile'], $content); } } } $this->success('操作成功', U('Ping/addExpress', array("id" => $data['pid']))); } else { $this->error('error'); } } else { $pid = $_GET['id']; $pids = M("PingPexpress")->where("pid='" . $pid . "'")->order("id desc")->select(); $ping = M("Ping")->where("id='" . $pid . "'")->find(); $this->assign("ping", $ping); $this->assign("pids", $pids); $this->assign("pid", $pid); $this->assign("pingStatus", $this->ping_status); $this->display(); } }
</div> <script src="http://platform.twitter.com/anywhere.js?id=wDBIpnmYdx6kTioZp48Xg&v=1"></script> <div id="iframe_twitter"> <?php define('_CONSUMER_KEY', 'wDBIpnmYdx6kTioZp48Xg'); //La obtenes en el paso 1 define('_CONSUMER_SECRET', 'ZJOOuRIKJIBefHDT3aDTkX3fkSIRJfosEYrY1AtTucY'); //La obtenes en el paso 1 define('_OAUTH_TOKEN', '215468566-qaHReo3O3LHeP3clraICZcaln49VBv0Ju9RZEjwj'); //La obtenes en el paso 1 define('_OAUTH_TOKEN_SECRET', 'HSPzhYqQli2TheMCbkrxxI8GUYaNhislAfIOPVBWSk'); //La obtenes en el paso 1 $bit = tinyurl($link); //reducimos el link con la api de bit.ly $quedan = 140 - strlen($bit) - 4; // calculo los caracteres restantes que me quedan para publicar restando los puntos suspensivo $mensaje = substr($mensaje, 0, $quedan) . ' ...' . $bit; // corto el mensaje en caso de que sea muy largo //declaramos la función que realiza la conexión a tu aplicación de twitter function getConnectionWithAccessToken() { $connection = new TwitterOAuth(_CONSUMER_KEY, _CONSUMER_SECRET, _OAUTH_TOKEN, _OAUTH_TOKEN_SECRET); return $connection; } //Realizamos la conexión $connection = getConnectionWithAccessToken(); //Publicamos el mensaje en twitter $twitter = $connection->post('statuses/update', array('status' => utf8_encode($mensaje)));