urlencode实际应用的代码。

jackxiang 2009-3-26 14:54 | |

<?php
    function request($url,&$result,$timeout=10) {
    $ctx = stream_context_create(array(
      'http' => array(
      'timeout' =>$timeout
      )
    ));
    $result = file_get_contents($url,false,$ctx);
    if ($result === false) {
      error_log("request $url   timeout",0);
      return 0;
    }
    return 1;
  }
define('BLOGBINDURL',"http://in-o.xianguo.com/sina/blogbind?");
//define('BLOGBINDURL',"http://localhost/get.php?");
  function bindblog($email,$uid,$blogurl,$action)
  {  
    $apikey = '4810512c96ee6'; //用于身份检验
    $time = time();
    $privete_key = "xianguosinapass";  
    $securitykey = md5($uid.$apikey.$time.$privete_key);//securitykey = md5(puid+apikey+time+privete_key)
    $encodeStr = "email=".urlencode($email)."&puid=".urlencode($uid)."&blogUrl=".urlencode($blogurl)."&action=".urlencode($action)."&apikey=".urlencode($apikey)."&time=".urlencode($time)."&securitykey=".urlencode($securitykey);
    $url = BLOGBINDURL.$encodeStr;  
    $flag = request($url,$result);
    
    if(1 == $flag)
    {      
      $resultReturn = json_decode($result);
      print_r($resultReturn);
      if(0 == $resultReturn['status'])
      return true;
      if(1 == $resultReturn['status'])
      return false;  
    }else
    {
      return false;  
    }
    
  }  
  
  $email = "xdy108@126.com";
  $uid = 1548940117;
  $blogurl = "http://blog.sina.com.cn/warsharp";
  $action = 0;  
  bindblog($email,$uid,$blogurl,$action);
  
?>

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1670/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]