How do I attach an image URL when tweeting through Fabric?


#1

Is there any way to attach a image url?
My code looks like this:

StringBuilder builder = new StringBuilder();
String description = entity.getString("description");
if (!TextUtils.isEmpty(description)) {
    builder.append(description);
}

String linkUrl = entity.getString("linkUrl");
if (!TextUtils.isEmpty(linkUrl)) {
    builder.append(linkUrl);
}
final String status = builder.toString();

String imageUrl = entity.getString("imageUrl");

StatusesService statusesService =
        apiClient.getStatusesService();
Call<Tweet> callTweet = statusesService.update(status,
        null,// in_reply_to_status_id
        false, // possibly_sensitive
        null, // lat
        null, // long
        null, // place_id
        false, // display_cooridnates
        false, // trim_user
        imageUrl); // media_ids

try {
    Response<Tweet> tweetResponse = callTweet.execute();
    if (tweetResponse.isSuccessful()) {
        if (listener != null) {
            listener.onSuccess(true);
        }
    } else {
        if (listener != null) {
            listener.onFailed(ErrorCode.PLATFORM_SHARE_FAILED, "empty");
        }
    }
} catch (Exception e) {
    if (listener != null) {
        listener.onFailed(ErrorCode.PLATFORM_SHARE_FAILED, e.getMessage());
    }
}

but I get a Exception: Http status 400.


How to post tweet pragmatically without touching the tweet button
#2

Hey @iceliushuai,

I moved your post to a new thread as it wasn’t applicable to the one it was posted under. You can see the answer to a similar question here: https://twittercommunity.com/t/how-to-share-image-url-with-twitter/68790/7?u=bonnell Currently this isn’t possible.