Å··ÉÊÖ»ú³äÖµ½Ó¿ÚphpÔ´´úÂëv0.1
×î½üÐèÒªÔÚ¹«Ë¾ÍøÕ¾ÉÏ×ö¸öÊÖ»ú³äÖµ¹¦ÄÜ,ÁªÏµÁ˺ü¸¸öÌṩÊÖ»ú³äÖµ·þÎñ½Ó¿ÚµÄÉ̼Ò×îºóÑ¡ÔñÁËÅ··ÉÊý¿¨,дÁ˸öÅ··ÉµÄÊÖ»úÖ±³ä½Ó¿Ú,¿ÉÒÔÖ§³ÖÈ«¹úÒƶ¯,ÁªÍ¨ºÍµçÐÅÊÖ»úµÄÖ±³ä»¨·Ñ,ÏÖÔÚ¹«²¼ÎҵĴúÂë¸ø´ó¼Ò²Î¿¼,Ï£Íû¿ÉÒÔ°ïÖúµ½ÓÐͬÑùÐèÇóµÄÅóÓÑ,ҲϣÍû´ó¼Ò°ïÎÒÌôÏÂÎÊÌâ.
²Î¿¼Îĵµ:OFCARDϵͳhttp½Ó¿ÚÐÒé(V5.3)
ÊÖ»úÖ±³ä½Ó¿Ú´úÂëÈçÏÂ:(Çë²Î¿¼´úÂë×¢ÊͽøÐÐÐÞ¸Ä)
<?php /* * Å··É½Ó¿Úv4.0·þÎñ¿ØÖÆ * ²Î¿¼£ºOFCARDϵͳhttp½Ó¿ÚÐÒé(V5.3) * °æ±¾ £º0.1 * ×÷Õߣºhttp://www.heui.org * ÈÕÆÚ£º20110219 */ class ofcard_service { var $gateway ; //ÊÖ»úÖ±³äÍø¹ØµØÖ· var $param ; //²éѯ²ÎÊý /** * ´ÓÅäÖÃÎļþ¼°Èë¿ÚÎļþÖгõʼ»¯±äÁ¿ * @param string $cardnum »°·ÑÃæÖµ * @param string $order_id ¶©µ¥ºÅ * @param string $game_userid ÊÖ»úºÅ * @param string $userid SP±àÂë * @param string $userpws SP½ÓÈëÃÜÂë * @param string $version Å··É½Ó¿Ú°æ±¾£¨¹Ì¶¨ÖµÎª£º4.0£© * @todo ÅäÖÃÎļþÊý×黯 */ function ofcard_service( $cardnum , $order_id , $game_userid , $userid , $userpws , $version ) { $this ->gateway = 'http://esales1.ofcard.com:8088/onlineorder.do ' ; $this ->param = array (); $this ->param[ 'userid' ] = $userid ; $this ->param[ 'userpws' ] = md5( $userpws ); //$this->param['cardid'] = '140101'; $this ->param[ 'cardid' ] = $this ->get_cardid( $game_userid ); $this ->param[ 'cardnum' ] = $cardnum /50; $this ->param[ 'sporder_id' ] = $order_id ; $this ->param[ 'sporder_time' ] = date ( 'YmdHis' ); $this ->param[ 'game_userid' ] = $game_userid ; $keystr = 'OFCARD' ; $this ->param[ 'md5_str' ] = strtoupper ( md5( $this ->param[ 'userid' ]. $this ->param[ 'userpws' ]. $this ->param[ 'cardid' ]. $this ->param[ 'cardnum' ]. $this ->param[ 'sporder_id' ]. $this ->param[ 'sporder_time' ]. $game_userid . $keystr ) ); $this ->param[ 'version' ] = $version ; } /** * ½øÐгäÖµ,ʹÓÃsnoopyÌá½» * @param Snoopy $snoopy * @param ezSQL_mysql $db * @param string $order_id * @return ³äÖµ½á¹û * @todo snoopy ¼¯³É */ function recharge( $snoopy , $db , $order_id ) { $snoopy ->submit( $this ->gateway, $this ->param); //ÏÂÃæÊý¾Ý¿â²Ù×÷ÊôÓÚÉ̼ÒÂß¼ $sql = "UPDATE `recharge` SET `is_recharge` = " . $this ->get_xml_value( "game_state" , $snoopy ->results) . ", `ofcard_trade_id` = '" . $this ->get_xml_value( "orderid" , $snoopy ->results) . "', `purchase_price` = '" . $this ->get_xml_value( "ordercash" , $snoopy ->results) . "' WHERE `order_id` = " . $order_id ; $db ->query( $sql ); return $this ->get_xml_value( "game_state" , $snoopy ->results); } /** * xmlÊý¾Ý¼òµ¥½âÎö * @param string $name * @param string $xml * @return string $ret */ function get_xml_value( $name , $xml ) { $ret = '' ; preg_match( "|<" . $name . ">(.*)</" . $name . ">|U" , $xml , $ret ); return $ret [1]; } /** * * »ñÈ¡³äֵ״̬ * http://202.102.53.141:83/api/query.do?userid=xxxxx&spbillid=spxxxxxx * @param string $userid SP±àÂë * @param string $spbillid ÉÌ»§ÏµÍ³¶©µ¥ºÅ * @return ³äֵ״̬ */ function get_is_recharge( $userid , $spbillid ){ $status_url = "http://202.102.53.141:83/api/query.do?userid= " . $userid . "&spbillid=" . $spbillid ; return file_get_contents ( $status_url ); } /** * * »ñÈ¡ÕË»§Óà¶î * @param string $userid * @param string $userpws * @param string $version * @return ÕË»§Óà¶î */ function get_leftcredit( $userid , $userpws , $version ) { $url = "http://esales1.ofcard.com:8088/queryuserinfo.do?userid= " . $userid . "&userpws=" . md5( $userpws ) . "&version=" . $version ; return self::get_xml_value( "ret_leftcredit" , file_get_contents ( $url )); } /** * ÊÇ·ñ¿ÉÒÔ³äÖµ(δ½øÐÐÓà¶îÅжÏ) * @param string $phoneno * @param string $price * @param string $userid * @return bool ÊÇ·ñ¿ÉÒÔ³äÖµ */ function is_recharge( $phoneno , $price , $userid ) { $url = "http://esales1.ofcard.com:8088/telcheck.do?phoneno= " . $phoneno . "&price=" . $price . "&userid=" . $userid ; $ret = split( '#' , file_get_contents ( $url )); return (1 == $ret [0]); } /** * * ËùÐèÌá»õÉÌÆ·µÄ±àÂë * (ÏÖÈ«¹úÒƶ¯ÁªÍ¨¿ì³äÖ±³ä±àÂëΪÇÒ½öΪ140101£¬µçÐÅÊÖ»ú±àÂëΪÇÒ½öΪ£±£¸) * @param string $phoneno ÊÖ»úºÅÂë * @todo ³£Á¿¼ÓÈëÅäÖÃÎļþ */ function get_cardid( $phoneno ) { $num = substr ( $phoneno , 0, 3); $ChinaMobile = array (134,135,147,147,136,137,138,139,150,151,152,182,157,158,159,187,188); $ChinaUnicom = array (130,131,132,155,156,145,185,186); $ChinaTelecom = array (133,153,180,189); if (in_array( $num , $ChinaMobile ) || in_array( $num , $ChinaUnicom )) { return '140101' ; } if (in_array( $num , $ChinaTelecom )) { return '18' ; } } }</pre>ÊÖ»úÖ±³ä½Ó¿ÚʹÓÃÈçÏÂ:</p> <p><pre class="brush: php">$ofcard = new ofcard_service( $original_price , $dingdan , $mobile , $userid , $userpws , $version ); $ofcard ->recharge( $snoopy , $db , $dingdan );´úÂë¸üÐÂÇëÁôÒâ:
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ