PHP清空新浪微博的代码


PHP #清空2012-06-03 19:21

直接上代码。

<?php
session_start();

include_once( 'config.php' );
include_once( 'saetv2.ex.class.php' );

$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );
$code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );

if (isset($_REQUEST['code'])) {
	$keys = array();
	$keys['code'] = $_REQUEST['code'];
	$keys['redirect_uri'] = WB_CALLBACK_URL;
	try {
		$token = $o->getAccessToken( 'code', $keys ) ;
	} catch (OAuthException $e) {
	}
}

if ($token) {
	$_SESSION['token'] = $token;
	setcookie( 'weibojs_'.$o->client_id, http_build_query($token) );
include('clear.php');
} else {
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新浪微博账户清空工具</title>
</head>

<body>
	<p>[新浪微博用户]你好!</p>
  <p >本工具用于清空你的微博账号的信息!清空操作<font color="red">不可逆</font>,请谨慎!</p>
		<hr />
	<p>什么是新浪微博清空工具?</p>
	<p>这是一个清空工具,可以清空微博用户关注过的用户,发布过的微博,收藏的话题,个性标签还有发出的评论!</p>
    <p>因为微博API的限制,将无法删除你的粉丝,也都无法删除别人给你的评论!</p>
  <p>每次删除收藏<font color="green">1000</font>条,评论<font color="green">1000</font>条,标签<font color="green">200</font>个,关注<font color="green">200</font>个,微博<font color="green">200</font>条,话题<font color="green">10</font>条!即使你填写的数量再多也是徒劳的!</p>
  <p>如果资源过多,请分开多次删除!因为微博API限制,建议你每次删除间隔<font color="#669999">600</font>秒!</p>
  <p>系统检测到你还没有授权!请授权后使用!</p>	
 <p><hr />
<a href="<?=$code_url?>"><img src="weibo_login.png" title="点击进入授权页面" alt="点击进入授权页面" border="0" /></a></p>

</body>
</html>

<?
}
?>

clear.php

<?php
/*
*
* 1.需要高级操作才能处理unread_count...
* 2.Tags接口有些时候无法删除资源,即使提示删除成功!
* 3.本文件推荐命名为clear.php
* 4.Author @淡淡清香弥漫世界
* 5.Blog www.lijingquan.net
* 6.需要自行添加config.php定义WB_AKEY,WB_SKEY,WB_CALLBACK_URL!
*
*/

session_start();

include_once( 'config.php' );
include_once( 'saetv2.ex.class.php' );

$c = new SaeTClientV2( WB_AKEY , WB_SKEY , $_SESSION['token']['access_token'] );

$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$ms[user] = $c->show_user_by_id($uid);
$ms[tags] = $c->get_tags($uid,1,200);
$ms[comments] = $c->comments_by_me();
$ms[friends] = $c->friends_ids_by_id($uid,0,200);
$ms[timeline] = $c->user_timeline_by_id($uid,1,200);
$ms[trend] = $c->get_trends($uid,1,10);
$ms[favorites] = $c->get_favorites();

$n[1]=$ms[user][followers_count];
$n[2]=$ms[user][friends_count];
$n[3]=$ms[user][statuses_count];
$n[4]=$ms[user][favourites_count];
$n[5]=count($ms[tags]);
$n[6]=count($ms[comments][comments]);
$n[7]=count($ms[trend]);

function maxin($a,$max){

if($m == 1 && $a>$max){ 
$a=$max;
return $a;
}else{
return $a;}
}

if($_POST[submit] == '清空'){
if($_POST[friends_count] < 200 || $_POST[statuses_count] < 200 || $_POST[favourites_count] < 1000 || $_POST[trends] < 10 || $_POST[tags] < 200 || $_POST[comments] < 1000){
$ms[tags] = $c->get_tags($uid,1,$_POST[tags]);
$ms[friends] = $c->friends_ids_by_id($uid,0,$_POST[friends_count]);
$ms[timeline] = $c->user_timeline_by_id($uid,1,$_POST[statuses_count]);
$ms[trend] = $c->get_trends($uid,1,$_POST[trends]);
foreach($ms[friends][ids] as $num => $val)
{
  $t = $c->unfollow_by_id($val);
  //print_r($t);
}
foreach($ms[timeline][statuses] as $num => $val)
{
  $t = $c->delete($val[id]);
  //print_r($t);
}
foreach($ms[trend] as $num => $val)
{
  $t = $c->unfollow_trends($val[trend_id]);
  //print_r($t);  
}
foreach($ms[comments][comments] as $num => $val)
{
  $t = $c->comment_destroy($val[id]);
  //print_r($t);  
}
foreach($ms[favorites][favorites] as $num => $val)
{
  $t = $c->remove_from_favorites($val[status][id]);
  //print_r($t);  
}
print_r($ms[tags]);
foreach($ms[tags] as $num => $val)
{
  $t = $c->delete_tag($val[weight]);
  //print_r($t);       
} 
}
$f = 'OK!';
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新浪微博账户清空工具</title>
</head>

<body>
	<p><? echo $ms[user][screen_name];?>你好!</p>
  <p >本工具用于清空你的微博账号的信息!清空操作<font color="red">不可逆</font>,请谨慎!</p>
	<? if($f == 'OK!'){echo '<p><font color="green">操作完成!</p>'; }; if($_POST[submit] == '清空'){
if($_POST[friends_count] > 200 || $_POST[statuses_count] > 200 || $_POST[favourites_count] > 1000 || $_POST[trends] > 10 || $_POST[tags] > 200 || $_POST[comments] > 1000){
  echo '<p><font color="red">';echo '表单上的操作数量有错误!';echo '</font></p>'; 
}}?>
	<hr />
	<p>什么是新浪微博清空工具?</p>
	<p>这是一个清空工具,可以清空微博用户关注过的用户,发布过的微博,收藏的话题,个性标签还有发出的评论!</p>
    <p>因为微博API的限制,将无法删除你的粉丝,也都无法删除别人给你的评论!</p>
  <p>每次删除收藏<font color="green">1000</font>条,评论<font color="green">1000</font>条,标签<font color="green">200</font>个,关注<font color="green">200</font>个,微博<font color="green">200</font>条,话题<font color="green">10</font>条!即使你填写的数量再多也是徒劳的!</p>
  <p>如果资源过多,请分开多次删除!因为微博API限制,建议你每次删除间隔<font color="#669999">600</font>秒!</p>
  <p>系统目前已经帮你获取<font color="blue"><? echo $n[1];?></font>个粉丝,<font color="blue"><? echo $n[2];?></font>个关注,<font color="blue"><? echo $n[3];?></font>条微博,<font color="blue"><? echo $n[4];?></font>条收藏,<font color="blue"><? echo $n[4];?></font>标签,<font color="blue"><? echo $n[5];?></font>条评论,<font color="blue"><? echo $n[7];?></font>条话题!</p>	
 <p><hr />
 <form action="weibolist.php" method="post">
粉丝:<input type="text" name="followers_count" value=<? echo $n[1];?>><br />
关注:<input type="text" name="friends_count" value=<? echo maxin($n[2],200);?>><br />
微博:<input type="text" name="statuses_count" value=<? echo maxin($n[3],200);?>><br />
收藏:<input type="text" name="favourites_count" value=<? echo maxin($n[4],1000);?>><br />
标签:<input type="text" name="tags" value=<? echo maxin($n[5],200);?>><br />
评论:<input type="text" name="comments" value=<? echo maxin($n[6],1000);?>><br />
话题:<input type="text" name="trends" value=<? echo maxin($n[7],10);?>><br />
<input type="submit" name="submit" value="清空"></form></p>

</body>
</html>


相关文章

粤ICP备11097351号-1