Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - twittpic

twittpic

Put your problem here if it does not fit any of the other categories.

twittpic

Postby rayman » Fri Jan 22, 2010 5:43 pm

Hi,
Ive been trying to use this twittpic code in order to post image in twitter, but the new sdk doesnt support many of the classes there, like:Part,MultipartRequestEntity,ByteArrayPartSource,StringPart
mybe anyone could help me to convert this code to a code which i could use in our last sdk(2.1)

/** @see <a href="http://twitpic.com/api.do">Twitpic api</a> */
public void twitpic(String username, String password, byte[] iconBytes) throws IOException {

HttpClient client = Utils.getHttpClient();

PostMethod method = new PostMethod("http://twitpic.com/api/uploadAndPost");

ArrayList<Part> partList = new ArrayList<Part>();
{
partList.add(new StringPart("username", username));
partList.add(new StringPart("password", password));
partList.add(new StringPart("message", "My status icon - "));
partList.add(new FilePart("media",
new ByteArrayPartSource("image.png", _convertToPNG(iconBytes)), "image/png", null
));
}

MultipartRequestEntity entity = new MultipartRequestEntity(
partList.toArray(new Part[0]), method.getParams()
);

method.setRequestEntity(entity);
client.executeMethod(method);

}

/** given any byte[] containing an image (gif/jpg/png/etc), will convert it to a png image */
private byte[] _convertToPNG(byte[] imgBytes) throws IOException {
BufferedImage bufimg = ImageIO.read(new ByteArrayInputStream(imgBytes));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufimg, "png", baos);
baos.flush();
return baos.toByteArray();
}


Thanks,
ray.
rayman
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Jan 11, 2010 11:26 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests