php - alle @mentions uit een tekst halen

Gestart doorOne2xs6 reacties9 weergaven

7 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Hoi..

Stel ik heb een string
string = @naam1 hoi @naam2 oké @naam3 oke is goed @naam4 haha

Nu wil ik dus, dat hij alle mentions eruit haalt..
Dus dat je krijgt

@naam1 @naam2 @naam3 @naam4

Het liefst, dat @naam2 @naam3 @naam4 geselecteerd zijn, zoals je bij Twitter for Mac hebt..

(strikt genomen de reply all functie van TweetDeck) (En wat Twitter web zelf standaard doet)

groet,
Jesse
0
Berichten
9.969
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Probeer iets in elkaar te zetten met preg_match / preg_match_all?
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Ben ik heel slecht in emo..
Maar ik zal eens googlen : )

toevoeging op 29 november 2012, 10:03:12:
eh oké..
tot nu toe is het best simpel..
Heb nu een array met alle @mentions erin smile
preg_match_all ("/@(.*) /U", $timeline[tweet], $test);

toevoeging op 29 november 2012, 10:56:03:
opgelost.
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb hier ooit een fucntie voor gemaakt die @ en # opzocht en verving met links naar twitter, zal even kijken of ik hem nog kan vinden

toevoeging op 29 november 2012, 12:56:27:
EDIT:

Laat maar zitten, was een functie die alleen werkte bij het ophalen van tweets via de Twitter API
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Welke functie is dat dan?
mijn hashtag ding werkt namelijk niet echt goed sadley
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] Tweet[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]){[/COLOR]
    [URL="http://www.php.net/global"]global[/URL] [COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]->[/COLOR]urls [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$Url[/COLOR][COLOR= #007700]){[/COLOR]
        [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$Url[/COLOR][COLOR= #007700]->[/COLOR]url[COLOR= #007700],[/COLOR] [COLOR= #DD0000]<a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Url[/COLOR][COLOR= #007700]->[/COLOR]url[COLOR= #007700].[/COLOR][COLOR= #DD0000]" target="_blank">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Url[/COLOR][COLOR= #007700]->[/COLOR]url[COLOR= #007700].[/COLOR][COLOR= #DD0000]</a>[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$string[/COLOR][COLOR= #007700]);
    }[/COLOR]
    
    [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]->[/COLOR]user_mentions [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$Mentions[/COLOR][COLOR= #007700]){[/COLOR]
        [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"@"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Mentions[/COLOR][COLOR= #007700]->[/COLOR]screen_name[COLOR= #007700],[/COLOR] [COLOR= #DD0000]"<a href=# onclick=window.open(""[/COLOR][COLOR= #007700].[/COLOR]_ROOT_[COLOR= #007700].[/COLOR][COLOR= #DD0000]"twitter/user/"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Mentions[/COLOR][COLOR= #007700]->[/COLOR]screen_name[COLOR= #007700].[/COLOR][COLOR= #DD0000]"", "Profiel van"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Mentions[/COLOR][COLOR= #007700]->[/COLOR]screen_name[COLOR= #007700].[/COLOR][COLOR= #DD0000]"", "toolbar=no,location=no,scrollbars=no,menubar=no,height=150px,width=510px")>@"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Mentions[/COLOR][COLOR= #007700]->[/COLOR]screen_name[COLOR= #007700].[/COLOR][COLOR= #DD0000]"</a>"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$string[/COLOR][COLOR= #007700]);
    }[/COLOR]
    
    [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tweet[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]->[/COLOR]hashtags [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$Hashtag[/COLOR][COLOR= #007700]){[/COLOR]
        [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]#[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Hashtag[/COLOR][COLOR= #007700]->[/COLOR]text[COLOR= #007700],[/COLOR] [COLOR= #DD0000]<a href="http://www.twitter.com/#!/search?q=%23[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Hashtag[/COLOR][COLOR= #007700]->[/COLOR]text[COLOR= #007700].[/COLOR][COLOR= #DD0000]" target="_blank">#[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Hashtag[/COLOR][COLOR= #007700]->[/COLOR]text[COLOR= #007700].[/COLOR][COLOR= #DD0000]</a>[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$string[/COLOR][COLOR= #007700]);
    }[/COLOR]
    
    [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$string[/COLOR][COLOR= #007700];
}[/COLOR]
?>


toevoeging op 29 november 2012, 15:42:28:
Waarbij $tweet dan de tweet is die via de API is opgehaald.
Weet alleen niet zeker wat string is, zou denken de tekst van de tweet maar weet het niet zeker
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