-1

我怎样才能得到这个网址:

http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&format=rest&api_key=xxx&perms=write&api_sig=xxx

进入:

http://api.flickr.com/services/auth/?api_key=xxx&perms=write&frob=xxx&api_sig=xxx

我从 XML 中提取并存储在字符串中的 frob 参数,所以它看起来像

String frob;
String originalURL;
//just need to join frob as well remove and rearrange accordingly 
4

1 回答 1

0

尝试这个:

var orgURL:String="http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&format=rest&api_key=xxx&perms=write&api_sig=xxx";
var index:int = orgURL.indexOf("api_key");
var newURL:String="http://api.flickr.com/services/auth/?"+orgURL.substr(index)+"&frob=xxx";

甚至更简单:

var orgURL:String="http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&format=rest&api_key=xxx&perms=write&api_sig=xxx";
var newURL:String="http://api.flickr.com/services/auth/?"+orgURL.substr(orgURL.indexOf("api_key"))+"&frob=xxx";

可能有一种使用正则表达式的方法,但是这个更容易理解:)

于 2012-09-25T09:41:02.850 回答