Click here to Skip to main content
15,908,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to get video id from this facebook url.

https://www.facebook.com/roflpot/videos/1012894442115859

How can i get 1012894442115859 using asp.net?

Thanks in advance

What I have tried:

string str = test.Substring(test.LastIndexOf('/') + 1);
Posted
Updated 26-Feb-16 1:50am
Comments
ZurdoDev 26-Feb-16 7:39am    
That code works. What exactly is your question?

1 solution

if always url have videoid at last place then try this code
C#
string[] words = test.Split(' ');

string str = words[words.Length-1];


OR

C#
string[] words = test.Split(' ');

string str = words[Array.IndexOf(words,"videos")+1];
 
Share this answer
 
v2
Comments
Ajith_joseph 26-Feb-16 8:03am    
Thank you for your answer. If it is not at last place?
See this video id(1012894442115859)

https://www.facebook.com/roflpot/videos/vb.573031789435462/1012894442115859/?type=2&theater

Thanks again.
mehul bhalala 26-Feb-16 8:11am    
Try this
another way to find

string[] words = test.Split(' ');

string str = words[Array.IndexOf(words,"videos")+1];

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900