BP Forums
Retrieving the source of a tweet using TwitterVB - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Code Snippets (https://bpforums.info/forumdisplay.php?fid=18)
+----- Thread: Retrieving the source of a tweet using TwitterVB (/showthread.php?tid=378)



Retrieving the source of a tweet using TwitterVB - brandonio21 - 08-04-2011

Someone asked me on one of my YouTube videos how to retrieve the source of a tweet. Well here is the code. This code is meant to be directly added into the source code found in this tutorial : <!-- m --><a class="postlink" href="http://www.youtube.com/watch?v=zd2gYBsCjqI&list=UUVwwElhbjWhU">http://www.youtube.com/watch?v=zd2gYBsC ... wwElhbjWhU</a><!-- m -->

Code:
Dim source As String = ""
If entry.Source.ToString.Contains("<") Then
'Source is link, get rid of link crap
source = entry.Source.ToString.Replace("</a>", "")
Dim int As Integer = source.LastIndexOf(">")
source = source.Remove(0, int + 1)
Else
source = entry.Source.ToString
End If
'Source variable is now ready to use
n.SubItems.Add(source)
In this code, the variable named 'Source' actually contains the information about where a tweet was posted from.

Hope this helps!


Re: Retrieving the source of a tweet using TwitterVB - jaydude28 - 08-08-2011

Hello,

I am the person who posted the comment on your youtube video. This was exactly what I needed to figure out. Thanks for helping me out. Looking forward to many more of your great tutorials on Visual Basic. Keep up the great work!


Re: Retrieving the source of a tweet using TwitterVB - jaydude28 - 08-08-2011

What is the proper way to save the tokens that twitter returns after validating the PIN? I heard you mention something in one of the tutorials about it. I'm pretty new to VB, so any help you can provide would be great.


Re: Retrieving the source of a tweet using TwitterVB - brandonio21 - 08-09-2011

What you should do is save the tokens in a text file with the name of the username. Then type in the Key and key secret, and split them with something like a /

Then, read the text file, and split the text by a / and there you go, you have your two strings.

Hopefully this was easy to understand, if not, let me know!


Re: Retrieving the source of a tweet using TwitterVB - jaydude28 - 08-09-2011

Thanks for the quick reply. I see what you talking about. I'm more of a visual learner, so if you could provide some source code to achieve this, it'd be cool. Thanks again.