例如,当视频上传到视频共享平台时,它返回一个回调URL-通知视频已完全上传的URL。
docs of the Video Indexer API,服务所提供的回调URL将在我要解析的查询中包含videoID,并在我自己的查询字符串中使用它。
例如,如果回调URL为'https://test.com/notifyme?projectName=MyProject',则通知将发送到'https://test.com/notifyme?projectName=MyProject&id=12345abcde&state=Processed'。
我想解析该id
查询字符串参数,以便可以在我的网页链接中使用它:https://fiddle.jshell.net/spe0xocq/1/show/light?
我试图做的是使用substring和indexOf。
例如:var queryString = url.substring( url.indexOf('?') + 1 );
但是我不确定这是否正确,因为我没有得到想要的结果。
您可以只使用:
var qs = url.split('=')[2].split('&')[0];
它将为您提供此网址中的ID您可以使用split方法将字符串拆分为数组。