peoy Posted February 18, 2011 Share Posted February 18, 2011 If you look at the botton of http://getminecraft.net/ you see my latest tweets. The problem is that it shows http://getminecraft.net/%22http://twitter.com/PC_Gamer%22 instead of the original twitter url, that results to a wrong url and wrong site. How can I fix it? so it shows the original twitter url. Here is the script: <?php $username = "getminecraft"; $prefix = ""; $suffix = ""; $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1"; function parse_feed($feed) { $stepOne = explode("<content type=\"html\">", $feed); $stepTwo = explode("</content>", $stepOne[1]); $tweet = $stepTwo[0]; $tweet = str_replace("<", "<", $tweet); $tweet = str_replace(">", ">", $tweet); return $tweet; } $twitterFeed = file_get_contents($feed); echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix); ?> Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/ Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Add a space in your echo line. Like this perhaps: echo stripslashes($prefix) . " " . parse_feed($twitterFeed) . " " . stripslashes($suffix); That will hopefully break up the link and the text before it, which means the text before it won't also be assigned the hyperlink... Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175927 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 Thank you very much, but that did not change anything Add a space in your echo line. Like this perhaps: echo stripslashes($prefix) . " " . parse_feed($twitterFeed) . " " . stripslashes($suffix); That will hopefully break up the link and the text before it, which means the text before it won't also be assigned the hyperlink... Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175930 Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Can you please tell me which parts of the twitter feed correspond to the 3 parts of the echo? Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175935 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 Im not sure actually, since I got this script from a site, since I wasnt sure how to write a simple twitter script. Thanks. Can you please tell me which parts of the twitter feed correspond to the 3 parts of the echo? Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175938 Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Well then change the script to only echo one thing at a time.. Or instead of adding the space between each element, add a separator as such: echo stripslashes($prefix) . " | " . parse_feed($twitterFeed) . " | " . stripslashes($suffix); Then you will clearly see which part belongs to what. Infact, are you able to do that and then upload it to your site so I may see as well? Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175941 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 I have added | now. As you can see, I dont think they are part of the url. thanks Im not sure actually, since I got this script from a site, since I wasnt sure how to write a simple twitter script. Thanks. Can you please tell me which parts of the twitter feed correspond to the 3 parts of the echo? Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175944 Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Alright so now we know that the link is being printed using parse_feed($twitterFeed) Can you also add the extra line you see below: $tweet = str_replace("<", "<", $tweet); $tweet = str_replace(">", ">", $tweet); $tweet = str_replace(""",""", $tweet); //you may nee to add a backslash before the double quote that's inbetween double quotes (the middle argument) Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175949 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 awesome! it is working very nice! want any credits? Also, if you do a codeclean up on that pure HTML site kit on that site, can add your site url and nick to that site kit have many uniqe visitors Alright so now we know that the link is being printed using parse_feed($twitterFeed) Can you also add the extra line you see below: $tweet = str_replace("<", "<", $tweet); $tweet = str_replace(">", ">", $tweet); $tweet = str_replace(""",""", $tweet); //you may nee to add a backslash before the double quote that's inbetween double quotes (the middle argument) Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175950 Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 awesome! it is working very nice! want any credits? Also, if you do a codeclean up on that pure HTML site kit on that site, can add your site url and nick to that site kit have many uniqe visitors Absolutely no idea what you're talking about there mate.... Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175953 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 If you go to that site. there is a fan site kit in a html file, if you do a html clean up so it gets valid html.. I can credit you on that site kit thing.. you'll just have to take a look, if you dont understand: thank you anyways! love and hugs! awesome! it is working very nice! want any credits? Also, if you do a codeclean up on that pure HTML site kit on that site, can add your site url and nick to that site kit have many uniqe visitors Absolutely no idea what you're talking about there mate.... Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175954 Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Oh right. I'm happy to help you with problems, I'm not going to spend time cleaning your code though to make it look nice, that's something you need to do . One suggestion though, if you want people to stay on your site, then you should make your external links open in a new window. You should also let people know that the links are to external sites, as I thought it was a navigation bar, which it isn't really.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175957 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 Hehe thanks.. added target="_blank" now.. gonna find out a clever way to inform people about those extarnal links tomorrw! Oh right. I'm happy to help you with problems, I'm not going to spend time cleaning your code though to make it look nice, that's something you need to do . One suggestion though, if you want people to stay on your site, then you should make your external links open in a new window. You should also let people know that the links are to external sites, as I thought it was a navigation bar, which it isn't really.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175963 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 Go have a lookie now.. a quick fix Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175971 Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Don't make External URLs: look like a button. All you need to have is some text along the topline of the bar saying something like "Check out these sites:". Something along those lines. But it's your site, so make it how you like it . Denno Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175973 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 okei:) thanks! gonna fix that Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1175974 Share on other sites More sharing options...
peoy Posted February 18, 2011 Author Share Posted February 18, 2011 I have now re-designed the whole page! even more simple! maybe I will make the links look pretty one day! Quote Link to comment https://forums.phpfreaks.com/topic/228049-simple-php-twitter-script/#findComment-1176539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.