我试图从一些CURL代码转换为FLEX/ActionScript。 因为我对CURL百分之百无知,50%对于Flex一无所知,90%对HTTP一无所知... 我有一些重大的困难。将CURL转换为FLEX HTTPRequests
,下列curl代码为http://code.google.com/p/ga-api-http-samples/source/browse/trunk/src/v2/accountFeed.sh
我有充分的理由相信,它的正常工作。
USER_EMAIL="[email protected]" #Insert your Google Account email here
USER_PASS="secretpass" #Insert your password here
googleAuth="$(curl https://www.google.com/accounts/ClientLogin -s \
-d Email=$USER_EMAIL \
-d Passwd=$USER_PASS \
-d accountType=GOOGLE \
-d source=curl-accountFeed-v2 \
-d service=analytics \
| awk /Auth=.*/)"
feedUri="https://www.google.com/analytics/feeds/accounts/default\
?prettyprint=true"
curl $feedUri --silent \
--header "Authorization: GoogleLogin $googleAuth" \
--header "GData-Version: 2"
以下是我失败的企图上述卷曲转化为AS3
var request:URLRequest=new URLRequest("https://www.google.com/analytics/feeds/accounts/default");
request.method=URLRequestMethod.POST;
var GoogleAuth:String="$(curl https://www.google.com/accounts/ClientLogin -s " +
"-d [email protected] " +
"-d Passwd=secretpass " +
"-d accountType=GOOGLE " +
"-d source=curl-accountFeed-v2" +
"-d service=analytics " +
"| awk /Auth=.*/)";
request.requestHeaders.push(new URLRequestHeader("Authorization", "GoogleLogin " + GoogleAuth));
request.requestHeaders.push(new URLRequestHeader("GData-Version", "2"));
var loader:URLLoader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, GACompleteHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, GAErrorHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, GAErrorHandler);
loader.load(request);
这可能为您提供各种具有良好的笑,那也没关系,但如果你能找到任何可怜我,请让我知道我错过了什么。我很乐意承认功能上的不足,因此让我知道我是多么愚蠢是可选的。