Share text with picture to telegram - java

I want to create an app in Android and I want to share text with a picture to telegram but I do not want the pictures and the text to be separated. I don't know how to do this.

Hopefully it works fine, I tried same.
$.sendPhoto(image_url,{caption : 'i am attached text with image'});
//bot.sendPhoto(chatId,image_url,{caption : 'i am attached text with image'}); /* TRY these according to you.
Or, if you want to send it from Telegram rest api, then call this api:
API URL : 'https://api.telegram.org/bot'+token+'/sendPhoto?
chat_id='+chatID+'&photo='+imageSrc+'&caption='+(message ?message : '');
METHOD : GET

Related

How to access to my album images on Imgur as json format?

I'm a newbie and in progress learning to code. Currently, I'm learning to chap Retrofit & API but have meet a problem that don't have on Google,I researched 2 days ago but cannot :(
This is my all images that i uploaded in 1 album: https://imgur.com/gallery/3fEbSEz
This is all informations related to authorization that i just registered (i think so, i followed the API docs imgur):
Client Name Client ID Client Secret
Get Images Imgur e17abdfa6dd2f71 85411f4e553fd0a5aab2740ea48abe296c8370bf
Through this link: https://api.imgur.com/models/gallery_album , I tried copy paste and replace content in {} by 3fEbSEz.
Example: https://api.imgur.com/3/gallery/album/3fEbSEz/images but as you can see, it cann't access into my album and display as json file format.
I wanna see the result like this: https://jsonplaceholder.typicode.com/photos . Yupp, like this, but ... hmm, i tried many times :((
So who can help me for this case, thanks so much for all helping!!!
This is error be returned when i tried manual link

How to post Video with custom thumbnail picture using RestFB?

I can publish video with description using RestFB. I want to add thumbnail picture to video. How can I do that?
I tried to add some Parameter when publish as
Parameter.with("thumb", BinaryAttachment.with(fileName, fetchBytesFromImage(fileName)))
Parameter.with("picture", BinaryAttachment.with(fileName, fetchBytesFromImage(fileName)))
If publishing more than one BinaryAttachment, you have to add the fieldname to the BinaryAttachment.with method , put both BinaryAttachments in a List and use it in the publish method.
It looks like this:
fbClient.publish("me/videos", GraphResponse.class,
Arrays.asList(
BinaryAttachment.with("source","1.mp4",inputstream),
BinaryAttachment.with("thumb", "bla.jpg", fetchBytesFromImage("bla.jpg"))),
Parameter.with("description", "Test Thumb"));

replacing Result's html

I have an URL which shows me a coupon form based on id:
GET /coupon/:couponId
All the coupon forms are different and submit different POST params to:
POST /saveCoupon/:id
I want to have a convenient way of debugging my coupons and be able to have a way of viewing actual POST params submitted.
I've made a controller on URL POST /outputPOST/saveCoupon/:id which saves nothing, but prints to browser POST params received.
Now I want to have an URL like GET /changeActionUrl/coupon/:couponId which calls GET /coupon/:couponId and then substitutes form's action URL POST /saveCoupon/:id with POST /outputPOST/saveCoupon/:id .
In other words I want to do something like:
Result.getHtml().replace("/saveCoupon/","/outputPOST/saveCoupon/");
With this I can easily debug my coupons just by adding "/outputPOST" in the browser.
You could just use a bookmarklet and javascript to replace all of the forms' action attributes. That way your developer can do it with one click instead of changing urls.
Something like this will prefix all form actions on the page with "/outputPOST".
javascript:(function(){var forms=document.getElementsByTagName('FORM');for(i=0;i<forms.length;++i){forms[i].setAttribute('action','/outputPOST'+forms[i].getAttribute('action'));}})();
I don't understand, at least not everything ;)
In general you can debug every piece of Play app using debugger (check for your favorite IDE tips how to do that) - this will be always better, faster, etc etc, than modifying code only for checking incoming values.
I.e. Idea 13+ with Play support allows for debbuging like a dream!

Javascript/html - File upload

I have a news section where I can post some news.
-> Thumbnail , title and content
What I want:
The user should be able to upload an image file without leaving the page
-> progress bar
Send the file as a post request to my server.
Then I can get the image file from the post request, then I can resize/rename the image and upload it to amazon s3.
If I have to use a javascript library, I would prefere to use jquery.
This should looks something like this:
If I submit the news, I want to save the image path in my database. Now I would need a way to get the image name from my post method.
I've found some uploading solutions, but I have problems to understand how they are working.
http://blueimp.github.com/jQuery-File-Upload/
http://www.uploadify.com/
I only know get/post to retrieve information but they integrate somehow php files in the form.
for example:
$(function() {
$('#file_upload').uploadify({
'swf' : 'uploadify.swf',
'uploader' : 'uploadify.php'
// Put your options here
});
});
I am lacking information to do this on my own. What would you recommend me?
Ps: I am using Java with Play2
Uploadify is definitely the way to go.
All the steps for implementation are to be found here : http://www.uploadify.com/documentation/uploadify/implementing-uploadify/
You need to configure the path where your uploads go in the uploadify.php script.
As for amazon S3 here is an implementation : http://code.google.com/p/uploadify-amazon-s3/
I think onUploadSuccess method better fits than onSelect : http://www.uploadify.com/documentation/uploadify/onuploadsuccess/
You can do something like this from the documentation :
$(function() {
$("#file_upload").uploadify({
'swf' : '/uploadify/uploadify.swf',
'uploader' : '/uploadify/uploadify.php',
'onSelect' : function(file) {
alert('The file ' + file.name + ' was added to the queue.');
}
});
});
Where you can get the flename once it has been selected.
What you're asking for is a LOT really. But to get you started, have a look at this page (uses JQuery):
http://tutorialzine.com/2011/09/html5-file-upload-jquery-php/
The above link is a nice upload utility that you can use for drag-and-drop pretty easily, but it can be used by manually selecting files as well. Well documented.
As for resizing, I've used this with great success (PHP): simpleImage
simpleImage is REALLY easy to use and plug into your website.

Calling Java method from HTML link

I'm currently building a Twitter client in Java using the Twitter4J API. To create a Twitter "timeline", I am currently pulling data from Twitter such as profile images, tweets and usernames, then displaying them in a JTextPane, formatted using HTML. Code example below:
StringBuilder out = new StringBuilder();
try {
List<Status> statuses = HandleEvents.instance().twitter.getHomeTimeline();
out.append("<html>");
for (Status status : statuses)
{
out.append("<img src=\"").append(status.getUser().getProfileImageURL())
.append("\" width=30 height=30><b>").append(status.getUser().getName())
.append(":</b> ").append(status.getText())
.append("<br><br>");
}
out.append("</html>");
tweetsTextPane.setText(out.toString());
This displays a timeline of 20 tweets, separated by two line breaks. Under each tweet, I would like to place a simple hyperlink, called "Retweet", which calls one of my Java methods - HandleEvents.instance().twitter.retweetStatus(status.getId())
How would I got about doing this? Can the call be made directly between the tags, or do I have to make the call using JavaScript?
Any help would be appreciated. Many thanks.
You don't really need to have a hyperlink do you? Since it's a Swing app you could just add a JLabel that only looks like a hyperlink (but if you put in a little effort, it could behave like one as well). Add a listener for mouse clicks on that JLabel and you've can hook your current handler there.
On the other hand, if you do want actual HTML links, what you can do is implement your own HyperlinkListener.
Here are a couple of examples:
http://www.java2s.com/Tutorial/Java/0240__Swing/HyperlinkListenerExample.htm
http://www.java2s.com/Code/Java/Event/DemonstratingtheHyperlinkListener.htm
http://www.devx.com/tips/Tip/12997

Categories