Twitter script css

Gestart doorReins10 reacties25 weergaven

11 berichten · pagina 1 van 1

Reins

Lid · Topicstarter

Berichten
14.363
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoi,
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]
?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
echo $tweet.
;

= de tweet
Dus dan kan je doen:

echo
.$tweet.

;
0
Tgrm

Lid

Berichten
2.133
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Reinier schreef:
foreach($tweets as $tweet)
{
echo $tweet.
;
}
?>[/code]
Ik denk dat hij daar moet. biggrin
@ ^: Kan ook, ligt eraan of die lijn erin moet of niet. smile
0
Reins

Lid · Topicstarter

Berichten
14.363
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ok bedankt, zal het zo ff testen yummie
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Tgrm schreef:
Eerdere citaten tonen
Reinier schreef:
[COLOR= #0000BB]<?php[/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]div id[COLOR= #007700]=[/COLOR][COLOR= #DD0000]"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]/div[COLOR= #007700]>
}[/COLOR]
?>
Ik denk dat hij daar moet. biggrin
@ ^: Kan ook, ligt eraan of die lijn erin moet of niet. smile
Jou code faalt, Errors, Zie zelf
0
Tgrm

Lid

Berichten
2.133
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsie schreef:
Eerdere citaten tonen
Tgrm schreef:
Eerdere citaten tonen
Reinier schreef:
[COLOR= #0000BB]<?php[/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= #DD0000]<div id="tweet">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]<hr /></div>[/COLOR][COLOR= #007700];
}[/COLOR]
?>
Ik denk dat hij daar moet. biggrin
@ ^: Kan ook, ligt eraan of die lijn erin moet of niet. smile
Jou code faalt, Errors, Zie zelf

Klopt, ff vergeten dat et php was smile
0
Reins

Lid · Topicstarter

Berichten
14.363
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ok, dus ik moet het bestaande script ergens neerzetten op de pagina, en waar ik de tweets wil jou script? yummie
//snap het al
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Codeblok (Ergens bovenaan je pagina):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


function get_tweets($username, $count = 10)
{

$url = http://twitter.com/statuses/user_timeline/.urlencode($username)..json?count=.(int)$count;//Make the url
$ch = curl_init();//Initialise CURL
curl_setopt($ch, CURLOPT_URL, $url);//Set the url
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);//We want the data to return
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);//Of course, we dont want your script to run forever, so set a timeout
$json = curl_exec($ch);//Execute and get the page
curl_close($ch);//Close curl connection

$decode = json_decode($json);//Decode the json

$return = array();
foreach($decode as $tweet)
{

$return[] = $tweet -> text;//And the text to an array
}

return $return;//Return the array
}

$tweets = get_tweets(JE TWITTER NAAM, 10);
?>

En dan waar je je tweets wilt:

<div id="tweets">
[COLOR= #0000BB]<?php[/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= #DD0000]<div id="tweet">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];
}[/COLOR]
?>
</div>


Snap je? biggrin
0
Reins

Lid · Topicstarter

Berichten
14.363
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ah ja, bedankt! biggrincheck je pb ;p
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Dankje biggrin
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Serieus joh maak niet 3 topics xD
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren