Hoi,
hoe kan ik elke tweet een div meegeven?
Of heel het script 1 style? Gewoon tussen
Dit is het script:
hoe kan ik elke tweet een div meegeven?
Of heel het script 1 style? Gewoon tussen
en
zetten?Dit is het script:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] get_tweets[COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]10[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]http://twitter.com/statuses/user_timeline/[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/urlencode"]urlencode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000].json?count=[/COLOR][COLOR= #007700].(int)[/COLOR][COLOR= #0000BB]$count[/COLOR][COLOR= #007700];[/COLOR][COLOR= #FF8000]//Make the url[/COLOR]
[COLOR= #0000BB]$ch[/COLOR] [COLOR= #007700]=[/COLOR] curl_init[COLOR= #007700]();[/COLOR][COLOR= #FF8000]//Initialise CURL[/COLOR]
curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_URL[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//Set the url[/COLOR]
curl_setopt [COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_RETURNTRANSFER[COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//We want the data to return[/COLOR]
curl_setopt [COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_CONNECTTIMEOUT[COLOR= #007700],[/COLOR] [COLOR= #0000BB]10[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//Of course, we dont want your script to run forever, so set a timeout[/COLOR]
[COLOR= #0000BB]$json[/COLOR] [COLOR= #007700]=[/COLOR] curl_exec[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//Execute and get the page[/COLOR]
curl_close[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//Close curl connection[/COLOR]
[COLOR= #0000BB]$decode[/COLOR] [COLOR= #007700]=[/COLOR] json_decode[COLOR= #007700]([/COLOR][COLOR= #0000BB]$json[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//Decode the json[/COLOR]
[COLOR= #0000BB]$return[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$decode[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$return[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #0000BB]$tweet[/COLOR] [COLOR= #007700]->[/COLOR] text[COLOR= #007700];[/COLOR][COLOR= #FF8000]//And the text to an array[/COLOR]
[COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$return[/COLOR][COLOR= #007700];[/COLOR][COLOR= #FF8000]//Return the array[/COLOR]
[COLOR= #007700]}[/COLOR]
[COLOR= #0000BB]$tweets[/COLOR] [COLOR= #007700]=[/COLOR] get_tweets[COLOR= #007700]([/COLOR][COLOR= #DD0000]barackobama[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]10[/COLOR][COLOR= #007700]);[/COLOR][COLOR= #FF8000]//Get last 10 tweets of Barack Obama
//Foreach tweet display it in a new line[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tweets[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]<hr />[/COLOR][COLOR= #007700];
}[/COLOR]
?>

