emilh91 / groupme-api-client

An unofficial PHP wrapper for the GroupMe API
MIT License
2 stars 1 forks source link

ImageService - uploadImage stopped working #7

Open stdrew opened 4 months ago

stdrew commented 4 months ago

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 commented 3 months ago

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

stdrew commented 3 months ago

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);