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). 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. 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. 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). 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:
<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; 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.