PHP简易微博
php 简易雪花算法

php 简易雪花算法PHP简易雪花算法雪花算法,也被称为Twitter的雪花算法,是一种用于生成全局唯一ID的算法。
它的设计目标是在分布式系统中生成唯一的ID,以保证数据的一致性和准确性。
在PHP中,我们可以使用简易的雪花算法来生成唯一的ID。
雪花算法的原理很简单,它将一个64位的整数分成了几个部分:- 第一个部分是一个符号位,永远为0,表示正数。
- 第二部分是一个41位的时间戳,记录生成ID的时间。
- 第三部分是一个10位的机器ID,用来标识生成ID的机器。
- 第四部分是一个12位的序列号,用来标识同一毫秒内生成的不同ID。
在PHP中,我们可以使用以下代码实现简易的雪花算法:```php<?phpclass Snowflake {private $machineId; // 机器IDprivate $epoch; // 开始时间戳,可以根据自己的需求设置private $lastTimestamp = -1; // 上一次生成ID的时间戳private $sequence = 0; // 序列号public function __construct($machineId) {$this->machineId = $machineId;$this->epoch = strtotime('2020-01-01 00:00:00') * 1000; // 将开始时间转换为毫秒}public function generateId() {$timestamp = $this->getTimestamp();if ($timestamp < $this->lastTimestamp) {throw new Exception('Clock moved backwards!');}if ($timestamp == $this->lastTimestamp) {$this->sequence = ($this->sequence + 1) & 4095; // 序列号部分使用了与操作,限制在12位范围内if ($this->sequence == 0) {$timestamp = $this->tilNextMillis($this->lastTimestamp);}} else {$this->sequence = 0;}$this->lastTimestamp = $timestamp;// 生成ID$id = (($timestamp - $this->epoch) << 22) | ($this->machineId << 12) | $this->sequence;return $id;}private function getTimestamp() {return round(microtime(true) * 1000);}private function tilNextMillis($lastTimestamp) {$timestamp = $this->getTimestamp();while ($timestamp <= $lastTimestamp) {$timestamp = $this->getTimestamp();}return $timestamp;}}// 使用示例$snowflake = new Snowflake(1);$id = $snowflake->generateId();echo $id;>```以上代码就是一个简单的PHP雪花算法的实现。
php获取新浪微博数据API的实例代码

php获取新浪微博数据API的实例代码分享下php取得新浪微博数据API的一个例子,学习下在php编程中,使用新浪微博数据API进行开发的方法,感兴趣的朋友可以参考下。
php获取新浪微博数据API要取得新浪微博的数据,可以通过其提供的API,地址:open.weibo/wiki/API文档_V2。
获取数据的方法:复制代码代码示例:<?php/***通过新浪微博数据API取得微博数据*edit:jbxue*/functiongetWeiboData(){$count=15;//参数source后面输入你的授权号$url="api.weibo/2/statuses/home_timeline.json?source=12 3456789&count=".$count."&page=1";echo$url.'<br/>';$curl=curl_init();curl_setopt($curl,CURLOPT_URL,$url);//设置是否显示header信息0是不显示,1是显示默认为0//curl_setopt($curl,CURLOPT_HEADER,0);//设置cURL参数,要求结果保存到字符串中还是输出到屏幕上。
0显示在屏幕上,1不显示在屏幕上,默认为0curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);//要验*的用户名密码curl_setopt($curl,CURLOPT_USERPWD,"username:password" );$data=curl_exec($curl);curl_close($curl);$result=json_decode($data,true);echo'<pre>';print_r($result);echo'</pre>';}>说明:json_decode($data)会输出一个对象,而json_decode($data,true)则强制输出为数组。
微博页面php代码收集

//图片高度计算// 原始图片$img_path="/bmiddle/6e5c06b1jw1dymgm4p1gzj.jpg";//$img_path=$bmiddle_pic;if($img_path!=""){$max_width = 206;$max_height = 10000;list($width, $height) = getimagesize($img_path);$ratioh = $max_height/$height;$ratiow = $max_width/$width;$ratio = min($ratioh, $ratiow);// 新的高度和宽度$picW = intval($ratio*$width);$picH = intval($ratio*$height);}//微博时间显示$str="Tue Nov 06 09:37:29 +0800 2012";//$currentTimeStamp2=strtotime($str);$currentTimeStamp = time();$wbTimeStamp=strtotime($str);$difTimeStamp=$currentTimeStamp-$wbTimeStamp;$difMminutes=floor($difTimeStamp/60);$showTime = date("m月d日H:i",$wbTimeStamp);if ($difMminutes<60){$showTime=$difMminutes."分钟前";}elseif($difMminutes<60*12 and $difMminutes>=60){$showTime="今天".date("H:i",$wbTimeStamp);}//截取字符串$user_screen_name_temp = utf8Substr($strText,$fromlength,$cutlength);function utf8Substr($str, $from, $len){return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s','$1',$str);}//数字字符处理函数10000变1万+ function count4($str){$bar=floor($str);if ($bar>100000){$rt=floor($bar/10000)."万";}elseif ($bar>10000){$rt=floor($bar/10000)."万+";}//elseif($bar>1000){// $rt=floor($bar/1000)."千+";// }else{$rt=$str;}return $rt;}//获取传递的columnidif ($_REQUEST['columnid']!=""){$columnid=$_REQUEST['columnid'];}else{$columnid=1624; }//定义微博信息数组$statusesShow=array(//'created_at'=> $showTime,'id'=>$id,'title'=>$textinfo,'referer'=>$auto_titlelink,'url'=>$auto_titlelink,'width'=>$original_pic_w,'height'=>$original_pic_h,'thumbnail_pic'=>$thumbnail_pic,'bmiddle_pic'=>$bmiddle_pic,'original_pic'=>$original_pic,'screen_name'=>$screen_name,'profile_image_url'=>$profile_image_url,'created_at'=>$showTime,'reposts_count'=>count4($reposts_count),'comments_count'=>count4($comments_count));//将每条微博信息作为数组存入主数组$statusesShowAll[$n]=$statusesShow;$n=$n+1;//微博条数//$statusesShowAll["total_number"]=$n;echo json_encode($statusesShowAll);//php 数组转json$arr = array('name' =>'陈毅鑫','nick' => '深空','contact' => array('email' => 'shenkong at qq dot com','website' => '',));$json_string = json_encode($arr);echo $json_string;$obj = json_decode($json_string);$arr = (array) $obj;print_r($arr);//写文件$filename = 'test.txt';$somecontent = "添加这些文字到文件\n";// 首先我们要确定文件存在并且可写。
46款 开源微博工具开源软件

46款开源微博工具开源软件微博客平台 StatusNetStatusNet 的前身是 Laconica,是一个开源的微博客平台软件,采用 PHP开发。
StatusNet是个相当老牌的开源微博程序,相当多的国外微博网站都是基于它架设的。
不过StatusNet对于服务器的要求的确是多。
StatusNet的功能还是比较丰富的,除了微博必备的所有...更多StatusNet信息多媒体微博客平台 SharetronixSharetronix (blogtronix) 作为一个多媒体微博客平台,具备微博客必备的特性——相互关注、私信、收藏等,同时还具有内建的图片上传和视频分享(支持来自YouTube、MySpace、MetaCafe、Vimeo和Revver的视频)功能。
Sharetronix还拥有一套好友邀请系统,可以...更多Sharetronix信息微博客系统 Blurt.itBlurt.it是一个基于PHP/MySQL搭建的微博客系统,类似于Twitter。
用户可以在一个开放或私有的讨论群中与其他用户互交沟通。
此项目已改到这里。
更多Blurt.it信息微博客系统 LaconicaLaconica (音"luh-KAWN-ih-kuh")是一个微型博客系统,类似于twitter和叽歪网之类的东西Laconica 现在已经改名为StatusNet 使用Laconica 系统搭建的网站有:http://identi.ca/...更多Laconica信息微博客平台 JaikuEngineJaikuEngine是一个2007年被Google收购的微博客平台。
但是今年,Google决定在Google Code上将其完全开源。
JaikuEngine能够部署在Google AppEngine上,所以使用JaikuEngine 架设微博客社区可以说是一个完全免费的解决方案,您只需要拥有一个Google帐户,然后开...更多JaikuEngine信息微博客程序 EasyTalkEasyTalk 是一个国产的开源微博客程序,界面挺像饭否的,API接口也和饭否类似,基于PHP和MySQL。
新浪微博操作指南

新浪微博新手手册第一章微博入门--------------------------------------------------------------------------------------------------21.1什么是微博--------------------------------------------------------------------------------------------------21.2如何注册微博-----------------------------------------------------------------------------------------------21.3如何登录微博-----------------------------------------------------------------------------------------------31.4新手快速使用微博攻略-----------------------------------------------------------------------------------3第二章微博强大功能--------------------------------------------------------------------------------------------42.1发微博的几种方式----------------------------------------------------------------------------------------42.2话题----------------------------------------------------------------------------------------------------------62.3发图片-------------------------------------------------------------------------------------------------------72.4发视频-------------------------------------------------------------------------------------------------------72.5发音乐--------------------------------------------------------------------------------------------------------82.6投票----------------------------------------------------------------------------------------------------------92.7私信----------------------------------------------------------------------------------------------------------102.8评论、转发、收藏功能----------------------------------------------------------------------------------102.9关注和粉丝-------------------------------------------------------------------------------------------------10-------------------------------------------------------------------------------------------------------112.11个人标签---------------------------------------------------------------------------------------------------11第三章手机玩转微博--------------------------------------------------------------------------------------------113.1手机短信、彩信更新微博-------------------------------------------------------------------------------113.2手机WAP更新微博--------------------------------------------------------------------------------------123.3手机客户端更新微博-------------------------------------------------------------------------------------12第四章帐号设置--------------------------------------------------------------------------------------------------1 54.1昵称----------------------------------------------------------------------------------------------------------154.2个性域名----------------------------------------------------------------------------------------------------154.3修改密码----------------------------------------------------------------------------------------------------154.4密码及密保资料查询-------------------------------------------------------------------------------------164.5微博登录名忘记-------------------------------------------------------------------------------------------16第五章认证&合作-----------------------------------------------------------------------------------------------16 5.1为什么要进行身份认证?------------------------------------------------------------------------------165.2如何进行V认证与合作---------------------------------------------------------------------------------165.3通过身份认证后是否有特权---------------------------------------------------------------------------17第六章微博新功能、新活动上线----------------------------------------------------------------------------176.1微博群------------------------------------------------------------------------------------------------------17---------------------------------------------------------------------------------------------------186.3勋章-----------------------------------------------------------------------------------------------------------196.4举报不良信息-----------------------------------------------------------------------------------------------20第一章微博入门1.1什么是微博可以把微博理解为“微型博客”或者“一句话博客”。
ASP.NET实现QQ、微信、新浪微博OAuth2.0授权登录

不管是腾讯还是新浪,查看他们的API,PHP都是有完整的接口,但对C#支持似乎都不是那么完善,都没有,腾讯是完全没有,新浪是提供第三方的,而且后期还不一定升级,NND,用第三方的动辄就一个类库,各种配置还必须按照他们约定的写,烦而且乱,索性自己写,后期的扩展也容易,看过接口后,开始以为很难,参考了几个源码之后发现也不是那么难,无非是GET或POST请求他们的接口获取返回值之类的,话不多说,这里只提供几个代码共参考,抛砖引玉了。
我这个写法的特点是,用到了Session,使用对象实例化之后调用Login() 跳转到登录页面,在回调页面调用Callback() 执行之后,可以从Session也可以写独立的函数(如:GetOpenID())中获取access_token或用户的唯一标识,以方便做下一步的操作。
所谓绑定就是把用户的唯一标识取出,插入数据库,和帐号绑定起来。
1.首先是所有OAuth类的基类,放一些需要公用的方法public abstract class BaseOAuth{ public HttpRequest Request = HttpContext.Current.Request; public HttpResponse Response = HttpContext.Current.Response; public HttpSessionState Session = HttpContext.Current.Session; public abstract void Login(); public abstract string Callback(); #region 内部使用函数 /// <summary> /// 生成唯一随机串防CSRF攻击 /// </summary> /// <returns></returns> protected string GetStateCode() { Random rand = new Random(); string data = DateTime.Now.ToString("yyyyMMddHHmmssffff") + rand.Next(1, 0xf423f).ToString(); MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] md5byte = puteHash(UTF8Encoding.Default.GetBytes(data)); return BitConverter.ToString(md5byte).Replace("-", ""); } /// <summary> /// GET请求 /// </summary> /// <param name="url"></param> /// <returns></returns> protected string GetRequest(string url) { HttpWebRequest httpWebRequest = .WebRequest.Create(url) asHttpWebRequest; httpWebRequest.Method = "GET"; httpWebRequest.ServicePoint.Expect100Continue = false; StreamReader responseReader = null; string responseData; try { responseReader = new StreamReader(httpWebRequest.GetResponse().GetResponseStream()); responseData = responseReader.ReadToEnd(); } finally { httpWebRequest.GetResponse().GetResponseStream().Close(); responseReader.Close(); } return responseData; } /// <summary> /// POST请求 /// </summary> /// <param name="url"></param> /// <param name="postData"></param> /// <returns></returns> protected string PostRequest(string url, string postData) { HttpWebRequest httpWebRequest = .WebRequest.Create(url) as HttpWebRequest; httpWebRequest.Method = "POST"; httpWebRequest.ServicePoint.Expect100Continue = false; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; //写入POST参数 StreamWriter requestWriter = new StreamWriter(httpWebRequest.GetRequestStream()); try { requestWriter.Write(postData); } finally { requestWriter.Close(); } //读取请求后的结果 StreamReader responseReader = null; string responseData; try { responseReader = new StreamReader(httpWebRequest.GetResponse().GetResponseStream()); responseData = responseReader.ReadToEnd(); } finally { httpWebRequest.GetResponse().GetResponseStream().Close(); responseReader.Close(); } return responseData; } /// <summary> /// 解析JSON /// </summary> /// <param name="strJson"></param> /// <returns></returns> protected NameValueCollection ParseJson(string strJson) { NameValueCollection mc = new NameValueCollection(); Regex regex = new Regex(@"(\s*\bsp; } foreach (Match m in regex.Matches(strJson)) { mc.Add(m.Groups[2].V alue, m.Groups[3].Value); } return mc; } /// <summary> /// 解析URL /// </summary> /// <param name="strParams"></param> /// <returns></returns> protected NameValueCollection ParseUrlParameters(string strParams) { NameValueCollection nc = new NameValueCollection(); foreach (string p in strParams.Split('&')) { string[] ps = p.Split('='); nc.Add(ps[0], ps[1]); } return nc; } #endregion}2.QQ的OAuth类public class QQOAuth : BaseOAuth{ public string AppId = ConfigurationManager.AppSettings["OAuth_QQ_AppId"]; public string AppKey = ConfigurationManager.AppSettings["OAuth_QQ_AppKey"]; public string RedirectUrl = ConfigurationManager.AppSettings["OAuth_QQ_RedirectUrl"]; public const string GET_AUTH_CODE_URL = "https:///oauth2.0/authorize"; public const string GET_ACCESS_TOKEN_URL = "https:///oauth2.0/token"; public const string GET_OPENID_URL = "https:///oauth2.0/me"; /// <summary> /// QQ登录,跳转到登录页面 /// </summary> public override void Login() { //-------生成唯一随机串防CSRF攻击 string state = GetStateCode(); Session["QC_State"] = state; //state 放入Session string parms = "?response_type=code&" + "client_id=" + AppId + "&redirect_uri=" + Uri.EscapeDataString(RedirectUrl) + "&state=" + state; string url = GET_AUTH_CODE_URL + parms; Response.Redirect(url); //跳转到登录页面 } /// <summary> /// QQ回调函数 /// </summary> /// <param name="code"></param> /// <param name="state"></param> /// <returns></returns> public override string Callback() { string code = Request.QueryString["code"]; string state = Request.QueryString["state"]; //--------验证state防止CSRF攻击 if (state != (string)Session["QC_State"]) { ShowError("30001"); } string parms = "?grant_type=authorization_code&" + "client_id=" + AppId + "&redirect_uri=" + Uri.EscapeDataString(RedirectUrl) + "&client_secret=" + AppKey + "&code=" + code; string url = GET_ACCESS_TOKEN_URL + parms; string str = GetRequest(url); if (str.IndexOf("callback") != -1) { int lpos = str.IndexOf("("); int rpos = str.IndexOf(")"); str = str.Substring(lpos + 1, rpos - lpos - 1); NameValueCollection msg = ParseJson(str); if (!string.IsNullOrEmpty(msg["error"])) { ShowError(msg["error"], msg["error_description"]); } } NameValueCollection token = ParseUrlParameters(str); Session["QC_AccessToken"] = token["access_token"]; //access_token 放入Session return token["access_token"]; } /// <summary> /// 使用Access Token来获取用户的OpenID /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public string GetOpenID() { string parms = "?access_token=" + Session["QC_AccessToken"]; string url = GET_OPENID_URL + parms; string str = GetRequest(url); if (str.IndexOf("callback") != -1) { int lpos = str.IndexOf("("); int rpos = str.IndexOf(")"); str = str.Substring(lpos + 1, rpos - lpos - 1); } NameValueCollection user = ParseJson(str); if (!string.IsNullOrEmpty(user["error"])) { ShowError(user["error"], user["error_description"]); } Session["QC_OpenId"] = user["openid"]; //openid 放入Session return user["openid"]; } /// <summary> /// 显示错误信息 /// </summary> /// <param name="code">错误编号</param> /// <param name="description">错误描述</param> private void ShowError(string code, string description = null) { if (description == null) { switch (code) { case "20001": description = "<h2>配置文件损坏或无法读取,请检查web.config</h2>"; break; case "30001": description = "<h2>The state does not match. You may be a victim of CSRF.</h2>"; break; case "50001": description = "<h2>可能是服务器无法请求https协议</h2>可能未开启curl支持,请尝试开启curl支持,重启web服务器,如果问题仍未解决,请联系我们"; break; default: description = "<h2>系统未知错误,请联系我们</h2>"; break; } Response.Write(description); Response.End(); } else { Response.Write("<h3>error:<h3>" + code + "<h3>msg:<h3>" + description); Response.End(); } }}3.新浪微博的OAuth类public class SinaOAuth : BaseOAuth{ public string AppKey = ConfigurationManager.AppSettings["OAuth_Sina_AppKey"]; public string AppSecret = ConfigurationManager.AppSettings["OAuth_Sina_AppSecret"]; public string RedirectUrl = ConfigurationManager.AppSettings["OAuth_Sina_RedirectUrl"]; public const string GET_AUTH_CODE_URL = "https:///oauth2/authorize"; public const string GET_ACCESS_TOKEN_URL = "https:///oauth2/access_token"; public const string GET_UID_URL = "https:///2/account/get_uid.json"; /// <summary> /// 新浪微博登录,跳转到登录页面 /// </summary> public override void Login() { //-------生成唯一随机串防CSRF攻击 string state = GetStateCode(); Session["Sina_State"] = state; //state 放入Session string parms = "?client_id=" + AppKey + "&redirect_uri=" + Uri.EscapeDataString(RedirectUrl) + "&state=" + state; string url = GET_AUTH_CODE_URL + parms; Response.Redirect(url); //跳转到登录页面 } /// <summary> /// 新浪微博回调函数 /// </summary> /// <returns></returns> public override string Callback() { string code = Request.QueryString["code"]; string state = Request.QueryString["state"]; //--------验证state防止CSRF攻击 if (state != (string)Session["Sina_State"]) { ShowError("The state does not match. You may be a victim of CSRF."); } string parms = "client_id=" + AppKey + "&client_secret=" + AppSecret + "&grant_type=authorization_code&code=" + code + "&redirect_uri=" + Uri.EscapeDataString(RedirectUrl); string str = PostRequest(GET_ACCESS_TOKEN_URL, parms); NameValueCollection user = ParseJson(str); Session["Sina_AccessToken"] = user["access_token"]; //access_token 放入Session Session["Sina_UId"] = user["uid"]; //uid 放入Session return user["access_token"]; } /// <summary> /// 显示错误信息 /// </summary> /// <param name="description">错误描述</param> private void ShowError(string description = null) { Response.Write("<h2>" + description + "</h2>"); Response.End(); }}4.微信的OAuth类public class WeixinOAuth : BaseOAuth{ public string AppId = ConfigurationManager.AppSettings["OAuth_Weixin_AppId"]; public string AppSecret = ConfigurationManager.AppSettings["OAuth_Weixin_AppSecret"]; public string RedirectUrl = ConfigurationManager.AppSettings["OAuth_Weixin_RedirectUrl"]; public const string GET_AUTH_CODE_URL = "https:///connect/qrconnect"; public const string GET_ACCESS_TOKEN_URL = "https:///sns/oauth2/access_token"; public const string GET_USERINFO_URL = "https:///sns/userinfo"; /// <summary> /// 微信登录,跳转到登录页面 /// </summary> public override void Login() { //-------生成唯一随机串防CSRF攻击 string state = GetStateCode(); Session["Weixin_State"] = state; //state 放入Session string parms = "?appid=" + AppId + "&redirect_uri=" + Uri.EscapeDataString(RedirectUrl) + "&response_type=code&scope=snsapi_login" + "&state=" + state + "#wechat_redirect"; string url = GET_AUTH_CODE_URL + parms; Response.Redirect(url); //跳转到登录页面 } /// <summary> /// 微信回调函数 /// </summary> /// <param name="code"></param> /// <param name="state"></param> /// <returns></returns> public override string Callback() { string code = Request.QueryString["code"]; string state = Request.QueryString["state"]; //--------验证state防止CSRF攻击 if (state != (string)Session["Weixin_State"]) { ShowError("30001"); } string parms = "?appid=" + AppId + "&secret=" + AppSecret + "&code=" + code + "&grant_type=authorization_code"; string url = GET_ACCESS_TOKEN_URL + parms; string str = GetRequest(url); NameValueCollection msg = ParseJson(str); if (!string.IsNullOrEmpty(msg["errcode"])) { ShowError(msg["errcode"], msg["errmsg"]); } Session["Weixin_AccessToken"] = msg["access_token"]; //access_token 放入Session Session["Weixin_OpenId"] = msg["openid"]; //access_token 放入Session return msg["access_token"]; } /// <summary> /// 显示错误信息 /// </summary> /// <param name="code">错误编号</param> /// <param name="description">错误描述</param> private void ShowError(string code, string description = null) { if (description == null) { switch (code) { case "20001": description = "<h2>配置文件损坏或无法读取,请检查web.config</h2>"; break; case "30001": description = "<h2>The state does not match. You may be a victim of CSRF.</h2>"; break; case "50001": description = "<h2>接口未授权</h2>"; break; default: description = "<h2>系统未知错误,请联系我们</h2>"; break; } Response.Write(description); Response.End(); } else { Response.Write("<h3>error:<h3>" + code + "<h3>msg:<h3>" + description); Response.End(); } }}5.web.config配置信息<appSettings> <!--QQ登录相关配置--> <add key="OAuth_QQ_AppId" value="123456789" /> <add key="OAuth_QQ_AppKey" value="25f9e794323b453885f5181f1b624d0b" /> <add key="OAuth_QQ_RedirectUrl" value="/oauth20/qqcallback.aspx" /> <!--新浪微博登录相关配置--> <add key="OAuth_Sina_AppKey" value="123456789" /> <add key="OAuth_Sina_AppSecret" value="25f9e794323b453885f5181f1b624d0b" /> <add key="OAuth_Sina_RedirectUrl" value="/oauth20/sinacallback.aspx" /> <!--微信登录相关配置--> <add key="OAuth_Weixin_AppId" value="wx123456789123" /> <add key="OAuth_Weixin_AppSecret" value="25f9e794323b453885f5181f1b624d0b" /> <add key="OAuth_Weixin_RedirectUrl" value="/oauth20/weixincallback.aspx" /></appSettings>。
PHP-微博 实验报告

中北大学基于开源代码的web应用实训报告学生姓名:学号:学院:软件学院专业:软件开发与测试题目:博客系统指导教师1.设计任务概述(包括系统总体框图及功能描述)系统需求分析微博是一个功能模块,主要用于网上信息的交互,具体功能如下:1、微博管理模块微博是一个自定义的微小博客,博主可以发照片。
发微博与朋友们分享。
2、个人信息模块个人呢信息模块是针对拥有微博的个人,它可根据自身的需求、需要随时地在微博上博主可以根据自己的需求改变用户名称及头像等相关信息,以及设置信息的显示方式。
3、好友管理管理博主对其添加的好友进行管理。
系统运行流程在此模拟了系统运行的背景:运行系统后,首先会弹出前台用户登录对话框,对用户的身份进行认证。
进入微博后,博主可以发微博,传照片,查看好友及个人信息等功能;后台设计主要为删除修改用户信息及微博信息。
2.功能模块详细设计登陆界面认证过程认证成功登陆后进入微博好友列表个人信息相册发微博发布失败发照片服务中心服务热线后台登陆设计后台登陆时对其身份进行认证认证成功认证失败后台登陆成功界面管理用户显示用户显示微博显示所有微博,删除微博数据库设计核心代码<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type"content="text/html;charset=gb2312"/><title>我的首页-随时随地分享身边的新鲜事</title><script type="text/javascript"src="js/scrolltop.js"></script><script type="text/javascript"src="js/buttonlabel.js"></script><script language="javascript">function form_check(){if(document.form1.newstext.value==""){alert("对不起,内容不能为空!")document.form1.newstext.focus()return false}}</script><link rel="stylesheet"type="text/css"href="css/style.css"><link rel="stylesheet"type="text/css"href="css/a_style.css"><link rel="stylesheet"type="text/css"href="css/fontsstyle.css"><?phpinclude"connect/sql.php";$sql_persional="select*from blog_userpersional";$result_persional=mysql_query($sql_persional);$row_persional=mysql_fetch_array($result_persional);?></head><body style="background-image:url(image/background.jpg);height:1650px;"><div style="position:absolute;top:0px;left:0px;height:55px;width:1350px; background:#D2D2D2"><img src="image/logo.png"width="150"height="55"style="position:absolute; left:150px"><div><a href="content/news_content.php"onclick="labelclick_top1()" onmouseover="mouseOver_top1()"onmouseout="mouseOut_top1()"target="content" ><label id="buttonlabel_top1"style="position:absolute;top:0px;left:400px; width:100px;height:55px;background:#D2D2D2"><h7_index_1>首页</h7_index_1></label></a><a href="content/friends_content.php"onclick="labelclick_top2()" onmouseover="mouseOver_top2()"onmouseout="mouseOut_top2()"target="content" ><label id="buttonlabel_top2"style="position:absolute;top:0px;left:500px; width:100px;height:55px;background:#D2D2D2"><h7_index_1>好友</h7_index_1></label></a><a href="content/persional_content.php"onclick="labelclick_top3()" onmouseover="mouseOver_top3()"onmouseout="mouseOut_top3()"target="content" ><label id="buttonlabel_top3"style="position:absolute;top:0px;left:600px;width:100px;height:55px;background:#D2D2D2"><h7_index_2>个人信息</h7_index_2></label></a></div><div><img src="image/logoharf.PNG"style="position:absolute;top:10px;left:925px" width="25"height="25"><label id="name_ontitle"style="position:absolute;top:10px;left:950px; width:200px;height:30px;background:#D2D2D2"><h8><?php echo $row_persional['name'];?></h8></label><label id="explain_ontitle"style="position:absolute;top:30px;left:1000px; width:250px;height:15px;background:#D2D2D2"><h8>--<?php echo $row_persional['explain'];?></h8></label></div></div><div style="position:absolute;top:250px;left:150px;width:150px;height:1200px; background:#FCC2C2"><div><a href="content/news_content.php"onclick="labelclick1()" onmouseover="mouseOver1()"onmouseout="mouseOut1()"target="content"><label id="buttonlabel1"style="position:absolute;top:70px;left:0px;width:150px; height:50px;"><h7>新鲜事</h7></label></a><a href="content/album_content.html"onclick="labelclick2()" onmouseover="mouseOver2()"onmouseout="mouseOut2()"target="content"><label id="buttonlabel2"style="position:absolute;top:120px;left:0px;width:150px; height:50px;"><h7>相 册</h7></label></a></div><div><a href="upload/publish_bolg.php"onclick="labelclick3()" onmouseover="mouseOver3()"onmouseout="mouseOut3()"target="content"><label id="buttonlabel3"style="position:absolute;top:200px;left:0px;width:150px; height:50px;"><h7>写微博</h7></label></a><a href="upload/publish_photo.php"onclick="labelclick4()" onmouseover="mouseOver4()"onmouseout="mouseOut4()"target="content"><label id="buttonlabel4"style="position:absolute;top:250px;left:0px;width:150px; height:50px;"><h7>发照片</h7></label></a></div></div><div style="position:absolute;top:250px;left:300px;width:650px;height:1200px; background:#FFC"align="justify"><div style="position:absolute;top:0px;left:0px;width:650px;height:50px;"><h1> 亲,坐上时光机,分享你的故事吧,有什么新鲜事要告诉大家?</h1> </div><div style="position:absolute;top:50px;left:50px;width:550px;height:150px"><form action="upload/dealpublishblog.php"method="post"name="form1" onsubmit="return form_check()"><textarea name="newstext"style="position:absolute;top:0px;left:0px; width:550px;height:100px;"></textarea><select name="publishway"style="position:absolute;top:118px;left:380px; width:90px;height:20px;"><option value="1">公开</option><option value="2">仅好友可见</option><option value="3">仅自己可见</option></select><input style="position:absolute;top:110px;left:480px;width:60px;height:30px" type="submit"value="发布"/></form></div><div style="position:absolute;top:200px;left:0px;width:650px;height:1000px" id="content"><iframe name="content"src="content/news_content.php"scrolling=no width=650height=1000marginwidth=0marginheight=0frameborder=0></iframe></div></div><div style="position:absolute;top:250px;left:950px;width:250px;height:1200px; background:#FF9"><div style="position:absolute;top:0px;left:0px;width:250px;"><img name="portraitimg"src="<?php echo$row_persional['image'];?>" style="position:absolute;top:20px;left:20px"width="100"height="100"><label style="position:absolute;top:30px;left:135px;width:110px; height:30px"><h9><?php echo$row_persional['name'];?></h9></label><label><img name="vipimg"src="image/vip.jpg"style="position:absolute; top:50px;left:150px"width="50px"height="50px"></label><label><img src="<h3></h3>"style="position:absolute;top:96px;left:152px" width="20px"height="20px"></label></div><div></div><div><iframe name="datetime"src="datetime.html"scrolling="no"width="250" height="250"marginheight="0"marginwidth="0"frameborder="0" style="position:absolute;top:200px;left:0px"></iframe></div><div title="覆盖层"style="position:absolute;top:195px;left:0px;height:10px; width:250px;background:#FF9"></div><div title="覆盖层"style="position:absolute;top:390px;left:0px;height:100px; width:250px;background:#FF9"></div></div><div style="position:absolute;background:#AFFFFC;width:1050px;height:80px; left:150px;top:1450px;"><div align="center"style="position:relative;top:15px;"><a href="about.html"class="a_style"><h2_login_6>关于微博</h2_login_6></a> |<a href="service.html"class="a_style"><h2_login_6>客服中心</h2_login_6></a> |<a href="backstage/login_backstage.php"class="a_style"><h2_login_6>后台登陆</h2_login_6></a></div><div align="center"style="position:relative;top:25px;"><h2_login_7>©2012-338blog Inc.All Rights Reserved for 338</h2_login_7></div></div><div style="DISPLAY:none"id=goTopBtn><IMG border=0 src="image/backtop.jpg"></div><script type=text/javascript>goTopEx();</script></body></html>3.课程设计心得、存在问题及解决方法通过本次课程设计,我学到了很多的东西,比如:css,javascript等,当然只是学了一点点罢了。
新浪微博的API

1,开发流程技术规范与指南目录隐藏∙ 1 概述∙ 2 开发流程o 2.1 申请APPKEYo 2.2 应用创建及发布流程∙ 3 开发指南o 3.1 SDK简介及作用o 3.2 如何通过授权访问数据3.2.1 OAUTH认证o 3.3 如何访问匿名接口o 3.4 接口数据如何适当的缓存o 3.5 如何避免rate limito 3.6 技术咨询和建议通过何种途径询问概述API平台应用日益丰富,为了让开发者更容易了解开发流程;为了规范API的接口,需要制定开发规范;为了对开发者进行一些深层次的指导,让开发者怎样来最优的访问API接口,特此制定开发流程技术规范与指南。
开发流程申请APPKEY1. 进入2. 如果您有新浪微博账户,可以直接登录,没有则注册一个微博账户后登录3. 登录后进入我的应用,创建一个应用4. 创建完成后会生成对应的appkey,app_secret,记住:您的app_key别对外泄露。
应用创建及发布流程应用的创建及发布包括下面的流程,开发者可以根据应用当前的状态进行相应的操作开发指南SDK简介及作用SDK是特定语言实现的一个可以通用的API使用的工具,SDK实现了新浪开放平台的全部或大部分接口,以便开发者不用关心API接口细节,认证实现等,可以直接调用接口完成特定的功能。
支持新浪微博开放平台接口的SDK语言包括Adobe air,c++,c#,java,php,python,ios等,具体请参考SDK列表页面如何通过授权访问数据微博开放平台对外支持两种用户认证方式,Basic auth以及OAUTH认证微博开放平台对外支持两种用户认证方式,Basic auth以及OAUTH认证OAUTH认证OAUTH协议为用户资源的授权提供了一个安全的、开放而又简易的标准。
关于OAUTH协议可以参考使用OAUTH认证来获取微博数据介绍详细见:OAuth如何访问匿名接口为了方便一些应用在没有用户认证情况下需要获取一些数据,微博开放平台提供了一些匿名访问接口。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
题目:基于php的简易微博系统
简易微博系统说明文档
一、本系统使用的工具
前台界面设计采用Dreamweaver工具,编写php运用zendstudio,服务器采用Apache,数据库支持采用MySQL。
二、系统需求说明
1、用户注册、登录;
2、成功登陆,可以发布微博、评论微博、转发微博;
3、用户可以浏览所以用户的微博;
4、用户可以对喜欢的人进行关注。
三、数据要求说明
本系统使用MySQL数据库,经过分析微博系统,总共设计了6张表。
主要有用户表、微博表、回复表、关注关系表、图片表、私信表。
重要数据表的数据字典如下:
用户表tb_user
名称类型说明
id int 用户id
username varchar 用户名
password varchar 密码
sex varchar 性别
realname varchar 真实姓名
photo varchar 图片
address varchar 地址
回复表tb_answer
名称类型说明
id int 回复id fromUser_id int 回复者id toUser_id int 给回复者id blog_id int 回复的微博id content varchar 回复内容resTime datetime 回复时间
微播表tb_blog
名称类型说明
id int 微博id
user_id int 用户id content varchar 微博内容fromBlog_id int 转发自微博id fromUser_id int 转发自用户id fowardNum int 转发数量issueTime datetime 发布时间
关注关系表tb_res
名称类型说明
id int 关注关系id
focusing_id int 关注id
focused_id int 粉丝id
四、概要设计说明
1、简易微博系统功能结构图如下所示:初期设计页面,主要有登录页面、注册页面、登录成功之后的主页面。
页面设计简洁,易于用户操作。
简易微博系统
登录
注册
发布微博
查
看
微
博
添
加
关
注
转
发
微
博
评
论
微
博
查
看
关
注
查
看
粉
丝
2、根据系统功能,设计数据库。
数据库设计是核心部分,需要
对微博系统有很好的理解。
3、理解微博系统的业务逻辑之后,运用php结合数据库进行编码。
五、用户操作说明
1.用户在地址栏输入http://localhost/wei/index.php 进入首页面。
如下所示:
2.没有注册的用户点击“立即注册”进入注册页面,进行注册。
3.注册成功的用户输入用户名和密码进行登录,若用户名或密码错误则出现以下提示:
4.登录成功的用户进入主页面homePage.php 进行各种操作。
六、总结:
通过制作这个简单的微博系统,是我对php有了更深一层的认识。
在此期间,也提高了一些技能,但同时也存在问题。
主要是:对于php的用法还不熟练,不能够很好的利用面向对象的思想来进行实现。
导致了很多冗余的代码,代码重用效率下降。
对数据库的操作不熟练,在编写过程中出现了很多错误。
系统有待改进的地方是,私信没有完成,没有加载微博图片。
这些工作我会通过查找资料来努力完成。