GithubHelp home page GithubHelp logo

Comments (7)

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024 1

I could be wrong, but i think Curl can send only file on the local filesystem, without HTTP.
You could try to download the photo from google App Engine on your server before sending it on Telegram.

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024 1

Well, if you use a database or some otherway to store information, you can try this:
When you want to send a picture, check if there is a record on your db like photo | file_id and do a SendPhoto using just the file_id (you should also implement some check to see if the picture is still on the Telegram's servers), If it's not, download the picture on your local webserver, send it using curl, get the file_id from the reply, save the data on the database and delete the picture from your local storage. It's tediuos but the only solution i can see.

from telegrambotphp.

Saly121 avatar Saly121 commented on September 28, 2024

I added public $results to Telegram class to read the curl_exec($ch) and I tried this code:

        define('BUCKET','gs://<MY_BUCKET_ADDRESS>/folder/');
    $contents = file_get_contents("http://www.example.com/255.png");
    file_put_contents(BUCKET.'255.png',$contents);
    $img = my_curl_file_create(BUCKET.'255.png','image/png'); 
    $content = array('chat_id' => $chat_id, 'photo' => $img );
    $telegram->sendPhoto($content);
    $telegram->sendMessage(array('chat_id' => $chat_id ,'text' => "Result=".$telegram->results));

file has saved as 255.png in Bucket ,but I received this result :
Result={"ok":false,"error_code":400,"description":"Bad Request: Wrong persistent file_id specified: contains wrong characters or has wrong length"}

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

I don't think curl can handle the gs protocol. Try using a file on the local server, or download the png first and then send it using CURL

from telegrambotphp.

xpyctum avatar xpyctum commented on September 28, 2024

Upload a pictute and get file_id, then send file_id with message.

from telegrambotphp.

Saly121 avatar Saly121 commented on September 28, 2024

You're right and I already tried it but when you have to send hundreds of random pictures to bot users how to do it without uploading on my server and sending by multipart to telegram server to get file_Id.
My problem is that my bot is on google app engine server and it does not support direct addressing a file like: /directory/a.jpg and curl doesn't support gs://

from telegrambotphp.

Saly121 avatar Saly121 commented on September 28, 2024

Thanks for comments, after all I found out I had to use custom multipart form data which I got from here
if anyone else has problem with Curl in new php versions or file uploading from google cloud storage
to telegram I would recommend to use it . link from php website

from telegrambotphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.