<?php
session_start();
include_once( 'config.php' );
include_once( 'weibooauth.php' );
$c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] );
$ms = $c->home_timeline(); // done
$me = $c->verify_credentials();
?>
<h2><?=$me['name']?> 你好~ 要换头像么?</h2>
<form action="weibolist.php" >
<input type="text" name="avatar" style="width:300px" value="头像url" />
<input type="submit" />
</form>
<h2>发送新微博</h2>
<form action="weibolist.php" >
<input type="text" name="text" style="width:300px" />
<input type="submit" />
</form>
<h2>发送图片微博</h2>
<form action="weibolist.php" >
<input type="text" name="text" style="width:300px" value="文字内容" />
<input type="text" name="pic" style="width:300px" value="图片url" />
<input type="submit" />
</form>
<?php
if( isset($_REQUEST['text']) || isset($_REQUEST['avatar']) )
{
if( isset($_REQUEST['pic']) )
$rr = $c ->upload( $_REQUEST['text'] , $_REQUEST['pic'] );
elseif( isset($_REQUEST['avatar'] ) )
$rr = $c->update_avatar( $_REQUEST['avatar'] );
else
$rr = $c->update( $_REQUEST['text'] );
echo "<p>发送完成</p>" ;
}
?>
<?php if( is_array( $ms ) ): ?>
<?php foreach( $ms as $item ): ?>
<div style="padding:10px;margin:5px;border:1px solid #ccc">
<?=$item['text'];?>
</div>
<?php endforeach; ?>
<?php endif; ?>
php100的视频教程代码来的,,,可是我打开就显示
Notice: Undefined index: name in E:\xampp\htdocs\sina\weibolist.php on line 14
Warning: Illegal string offset 'text' in E:\xampp\htdocs\sina\weibolist.php on line 52
/
Warning: Illegal string offset 'text' in E:\xampp\htdocs\sina\weibolist.php on line 52
4
Warning: Illegal string offset 'text' in E:\xampp\htdocs\sina\weibolist.php on line 52
不知道那里错了,,,,求帮助在线,,,,
<h2><?=$me['name']?> 你好~ 要换头像么?</h2>
这个是不规范的写法·
<h2><?php if(isset($me['name'])) { echo $me['name'];}?> 你好~ 要换头像么?</h2>
<?php echo $item['text'];?>追问
这些都是notice··不是致命错误··你也可以关了它··不过最好修复一下
请问怎么修复?
不是给你写了么··上面那两个写法·
追问第一个解决了,,,后面三个还是这样
Warning: Illegal string offset 'text' in E:\xampp\htdocs\sina\weibolist.php on line 52
你把$item打印出来看看··看有些什么