作者:xjw4478688 | 来源:互联网 | 2023-09-25 18:13
Thisismyfirstquestion:).这是我的第一个问题。ImwritingalittletwitterappinPHPthatsendsaDMsto
This is my first question :).
这是我的第一个问题。
Im writing a little twitter app in PHP that sends a DMs to all your followers. What im trying to do right now is to get the list of followers. So through twitter api and getting all usernames but for some reason this parsing error appear. Im new to php(but not so much to programming), I actually started learning it yesterday so please be easy on me ;).
我用PHP写了一个小的推特应用,它会发送一个DMs给你的所有追随者。我现在要做的就是得到追随者的名单。通过twitter api获取所有用户名但是由于某种原因出现了解析错误。我对php还不熟悉(但对编程还不是很熟悉),我昨天就开始学了,所以请别对我太苛刻。
Here is the code:
这是代码:
$t= new twitter();
$t->username= $_GET["username"];
$t->password= $_GET["password"];
$fi = $t->followers();
$xml[$page] = new SimpleXMLElement($fi[2]);
$user1count=0;
while(isset($xml[$page]->user[0])){
foreach ($xml[$page]->user as $user) {
$userdet[(string)$user->screen_name]=array( ’screen_name’=> (string)$user->screen_name, ‘location’=>(string)$user->location, ‘description’=>(string)$user-> description, ‘profile_image_url’=> (string)$user-> profile_image_url, ‘url’=>(string)$user-> url, ‘name’=>(string)$user->name );
$user1details[$user1count]= (string)$user->screen_name;
$user1count++;
}
$page++;
$fi=getfilecontents($friendsurl.$username1."xml?page".$page);
if($fi[0]===false){
echo ("Error :".$fi[1]);
$err=new SimpleXMLElement($fi[2]);
echo " ".$err->error." ";
// echo ““;
die();
}
$xml[$page] = new SimpleXMLElement($fi[2]);
}
And the error said:
和错误的说:
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /Applications/XAMPP/xamppfiles/htdocs/scripts/dmsend.php:125 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/scripts/dmsend.php(125): SimpleXMLElement->__construct('') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/scripts/dmsend.php on line 125
致命错误:在/Applications/XAMPP/ XAMPP/xamppfiles/htdocs/scripts/ scripts/dmsend中,无法将带消息的字符串的未捕获异常“exception”解析为XML。php:栈125跟踪:#0 /应用/XAMPP/xamppfiles/htdocs/scripts/dmsend.php(125): SimpleXMLElement->__construct(" ") #1 {main})抛出/应用/XAMPP/xamppfiles/htdocs/scripts/ scripts/脚本/dmsend。php在第125行
Thank you! :)
谢谢你!:)
1 个解决方案