簡體   English   中英

使用Flash / Flex發布到Twitter

[英]Posting to twitter using Flash/Flex

我正在嘗試使用Flex(如果有任何區別,請使用Flex 3.5 SDK和Flex Builder 4)在我的Twitter上發布“ tweet”。 在mxml文件中,我創建了一個按鈕,只是為了使其易於調用AS3函數,並且在該函數中,我正在發出URL請求。 顯然我做錯了,因為我的推文沒有發布。 我在Twitter本身提供的curl請求中得到了這些變量,它實際上是有效的。 我的猜測是我格式化不正確,但是我不知道那是什么。...非常感謝您提供的任何幫助。 這是我正在使用的代碼:編輯:我想澄清一下我已經有適當的授權密鑰之類的(例如,我制作了Coldfusion腳本來處理該問題)。 我不需要授權方面的幫助,只需發布​​即可。

var postTO:URLRequest=new URLRequest("https://api.twitter.com/1/statuses/update.json");
var params:URLVariables = new URLVariables(
"include_entities=true&status=Maybe+he%27ll+finally+fiasdfasdfmnnd+his+kekjhjkys.+%23peterfalk&trim_user=true"+"&"+
    "status=Maybe+he%27ll+finally+fiasdfasdfmnnd+his+kekjhjkys.+%23peterfalk"+"&"+
    "trim_user=true"+"&"+
    "oauth_consumer_key=<myOauthConsumerKey>"+"&"+
    "oauth_nonce=<myOauthNonce>"+"&"+
    "oauth_signature=<myOauthSignature>"+"&"+
    "oauth_signature_method=HMAC-SHA1"+"&"+
    "oauth_timestamp=1331137102"+"&"+
    "oauth_token=<myOAuthToken>"+"&"+
    "oauth_version=1.0");
var loader:URLLoader = new URLLoader();

postTO.data=params;
postTO.method=URLRequestMethod.POST;
try {
    loader.load(postTO);
} catch (error:Error) {
    trace("Unable to load requested document.");
}

查看crossdomain.xml文件以獲取您要訪問的域:

<cross-domain-policy xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">
 <allow-access-from domain="twitter.com"/>
 <allow-access-from domain="api.twitter.com"/>
 <allow-access-from domain="search.twitter.com"/>
 <allow-access-from domain="static.twitter.com"/>
 <site-control permitted-cross-domain-policies="master-only"/>
 <allow-http-request-headers-from domain="*.twitter.com" headers="*" secure="true"/>
</cross-domain-policy>

除非您在Twitter上工作和/或有權在任何允許的域之外為SWF服務; 您將無法構建直接從Flash訪問這些URL的基於瀏覽器的應用程序,而必須使用您選擇的服務器端語言構建代理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM