1

how I can upload image on twitpic using as3 and flash professorial cs6 and i try the code below and nothing happened Thank's in advance

import flash.net.FileReference;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.utils.ByteArray;



var urlVars:URLVariables = new URLVariables();
urlVars.username = "xxxx";
urlVars.password = "xxxxx";

var urlRequest:URLRequest = new URLRequest("http://twitpic.com/api/upload");
urlRequest.method = URLRequestMethod.POST;
urlRequest.data = urlVars;

var file:File = File.desktopDirectory.resolvePath("test.png");
file.upload(urlRequest, 'media');
Enas S3efan
  • 81
  • 1
  • 11
  • Is this an Adobe AIR app? If not, you cannot use the `File` class. Instead, you must use `FileReference` – Josh May 20 '13 at 16:12
  • yes it is Adobe air 3.4 – Enas S3efan May 21 '13 at 07:17
  • I think it is not easy, you have to do the steps listed in the twitpic doc page: http://dev.twitpic.com/docs/2/upload/ including authenticating and adding 2 request headers. This is not easy to do by yourself. There are a lib I found but it is not ducumented nor test, if youlike to experiement find it here: https://code.google.com/p/twitpicscript/ – Mahmoud Badri Jul 26 '13 at 00:22
  • also this japanese tutorial looks promising (translate the page), it relies on external libraries to do the headers parts. also notice you`ll need a twitter app + a twitpic app to get the keys requested by the tutorial. http://exp777.hatenablog.com/entry/20120101/1325362428 – Mahmoud Badri Jul 26 '13 at 00:24
  • Thank's I try this before but will try again :) – Enas S3efan Jul 28 '13 at 06:37

0 Answers0