简体   繁体   English

使用Flash / Flex发布到Twitter

[英]Posting to twitter using Flash/Flex

I am trying to post a "tweet" to my twitter using Flex (using the Flex 3.5 SDK and Flex Builder 4 if that makes any difference). 我正在尝试使用Flex(如果有任何区别,请使用Flex 3.5 SDK和Flex Builder 4)在我的Twitter上发布“ tweet”。 On an mxml file I've created a button simply to make it easy to call an AS3 function, and in the function, I'm making a URL request. 在mxml文件中,我创建了一个按钮,只是为了使其易于调用AS3函数,并且在该函数中,我正在发出URL请求。 Obviously I'm doing something wrong, because my tweet ain't posting. 显然我做错了,因为我的推文没有发布。 I got these variables in the curl request provided by Twitter themselves, which actually worked. 我在Twitter本身提供的curl请求中得到了这些变量,它实际上是有效的。 My guess is that I'm formatting something incorrectly, but I don't know what that is....Thank you very much for any help you might provide. 我的猜测是我格式化不正确,但是我不知道那是什么。...非常感谢您提供的任何帮助。 Here is the code I'm using: EDIT: I would like to clarify that I already have the appropriate authorization keys and such (as I made a Coldfusion script to handle that). 这是我正在使用的代码:编辑:我想澄清一下我已经有适当的授权密钥之类的(例如,我制作了Coldfusion脚本来处理该问题)。 I do not need help with authorization, just posting. 我不需要授权方面的帮助,只需发布​​即可。

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.");
}

Review the crossdomain.xml file for the domain your accessing: 查看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>

Unless you are working for twitter and/or have access to serve your SWF off any of the allowed domains; 除非您在Twitter上工作和/或有权在任何允许的域之外为SWF服务; you won't be able to build a browser based app that accesses these URLs directly from Flash You'll have to build a proxy in the server side language of your choice. 您将无法构建直接从Flash访问这些URL的基于浏览器的应用程序,而必须使用您选择的服务器端语言构建代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM