twitter app status uitlezen en twitpic omzetten in img tag
Ik heb een klein probleem met mijn twitter app.
ik probeer de status uit te lezen van mijn twitter, dit gaat goed tot ik een twitpic wil omzetten naar een <img> tag zodat het plaatje getoond word ipv een link.
nu gebruik ik het volgende stukje code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?PHP
$text = $status->text;
$foo = $text;
$tmp = strip_tags($text);
// find a mention of twitpic
if (preg_match_all('#twitpic.com/([\d\w]+)#', $tmp, $matches, PREG_PATTERN_ORDER) > 0) {
foreach ($matches[1] as $match) {
$images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
}
$text = $foo . '<center>' . $images . '</center>';
}
return $text;
?>
$text = $status->text;
$foo = $text;
$tmp = strip_tags($text);
// find a mention of twitpic
if (preg_match_all('#twitpic.com/([\d\w]+)#', $tmp, $matches, PREG_PATTERN_ORDER) > 0) {
foreach ($matches[1] as $match) {
$images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
}
$text = $foo . '<center>' . $images . '</center>';
}
return $text;
?>
hier gaat echter iets mis, nu toont die geen enkel bericht meer en ik heb geen idee hoe ik dit moet oplossen.
kan iemand mij uit de brand helpen?
alvast bedankt.
edit: als ik de return verander in echo krijg ik de volgende melding:
Notice: Undefined variable: images in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\twitter_test\twitter_status.php on line 105
line 105 is:
Code (php)
1
2
3
2
3
<?PHP
$images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
?>
$images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
?>
ik blijf proberen en hoop op een antwoord :)
Gewijzigd op 05/06/2010 20:04:46 door Skippy Skefnietof
Skippy Skefnietof op 05/06/2010 19:47:35:
edit: als ik de return verander in echo krijg ik de volgende melding:
Notice: Undefined variable: images in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\twitter_test\twitter_status.php on line 105
line 105 is:
ik blijf proberen en hoop op een antwoord :)
Notice: Undefined variable: images in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\twitter_test\twitter_status.php on line 105
line 105 is:
Code (php)
1
2
3
2
3
<?PHP
$images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
?>
$images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
?>
ik blijf proberen en hoop op een antwoord :)
Bestaat er op dat moment al een $images?
Het geen wat jij daar namelijk doet is dat plaatje met de link in de $images zetten (of te wel: die moet al bestaan).