Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageService - uploadImage stopped working #7

Open
stdrew opened this issue Apr 27, 2024 · 4 comments
Open

ImageService - uploadImage stopped working #7

stdrew opened this issue Apr 27, 2024 · 4 comments

Comments

@stdrew
Copy link

stdrew commented Apr 27, 2024

Been using this function for a while with no issues, but realized recently it is returning a blank result array (no i.groupme picture_url to use)

No code changes since it worked to not working. Valid image is being sent with proper extension set.
Access Token is valid.

Having trouble pin-pointing the issue. The $url in $this->request points to a 404, but this is before a POST is done so may not be relevant.

I did update to php8, so could this be the reason in regards to the curl actions? (haven't been able to identify)

I realize this is not an actively updated repo, but if you are able to see what's not working anymore that'd be great!

@emilh91
Copy link
Owner

emilh91 commented Jun 6, 2024

Hi @stdrew - gee, I would like to to help. Can you post a code snippet?

@stdrew
Copy link
Author

stdrew commented Jun 8, 2024

Thanks! sure...


<?php

use GroupMeApi\Client;
use GroupMeApi\AttachmentUtils;

$text = "Here is a picture of a player.";
$img = "https://a.espncdn.com/i/headshots/nfl/players/full/4243331.png";

$gm = new Client($conf['GROUPME.token']);
$img_arr = $gm->uploadImage($img, 'image/png');
//! point of failure: blank array returned
//! used to return payload with new "i.groupme" picture_url

// prepare attachments
$attachments = [];
if ($img_arr) {
    $img_url = $img_arr["payload"]["picture_url"];
    $attachments[] = AttachmentUtils::makeImageAttachment($img_url);
}

// send it to the group
$send = $gm->sendBotMessage($conf['GROUPME.bot_id'], $text, $attachments);

// if successful, $send returns the img url created by groupme's image service
// ps) must use image service otherwise invalid origin error
print_r($send);

@emilh91
Copy link
Owner

emilh91 commented Jan 4, 2025

Hi @stdrew - apologies for the delay...
But I am not sure if uploading from a HTTP(s) URL was ever supported.
Even GroupMe's docs for image uploads specify a local file path.
Perhaps you can try downloading the file first?

$file_path = "/tmp/image.png";
$img_url = "https://a.espncdn.com/i/headshots/nfl/players/full/4243331.png";
file_put_contents($file_path, file_get_contents($img_url));
$img_arr = $gm->uploadImage($file_path, 'image/png');

@stdrew
Copy link
Author

stdrew commented Jan 5, 2025

Thanks for looking at it. Yeah, I just gave a remote image as an example but was using both HTTPS and local images, and both were working fine as source image for your uploadImage function. The error seems to arise there even with local file path.

I don't think your code changed and it just started happening so wasn't sure what was going on. Assumed PHP 17 to 18 issue back then but that couldn't be identified.

No worries. Maybe I can try sending the post with guzzle or something and see how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants