etsy-php
etsy-php copied to clipboard
uploadListingImage leads to Exception
Hi there
when using uploadListingImage()
I'm getting an Exception: Uploading files using php_streams request engine is not supported in vendor/inakiabt/etsy-php/src/Etsy/EtsyClient.php:52
I'm using it like written in the example:
$listing_image = array(
'params' => array(
'listing_id' => '152326352'
),
'data' => array(
'image' => array('@/path/to/file.jpg;type=image/jpeg')
));
print_r($api->uploadListingImage($listing_image));
What's wrong or missing?
In order to upload files you need to ~use the OAuth
PHP extension~ have cURL installed and reinstall the OAuth
PHP extension.
See https://github.com/inakiabt/etsy-php/blob/master/src/Etsy/EtsyClient.php#L25
The plan is to remove this dependency, but I didn't have time, that's why https://github.com/inakiabt/etsy-php#im-looking-for-help 😀
Thanks for your answer and your links. I then thought reinstalling oauth could be the solution because that is what I haven't tried so far but it just doesn't want to work. Maybe also because there is another conflict because oauth was also installed using apt-get install php-oauth
with php7. I'm currently thinking about giving up on this because your lib is fine but old crappy php just doesn't want to work :/
@quape just install libcurl4-dev
I have the same problem with error Exception 'Exception' with message 'Uploading files using php_streams request engine is not supported'
in /vendor/inakiabt/etsy-php/src/Etsy/EtsyClient.php:52
.
It has worked some time ago.
I am using Debian Stretch which offers three different libcurl4-dev:
- libcurl4-openssl-dev
- libcurl4-nss-dev
- libcurl4-gnutls-dev The first is installed.
The php-oauth is installed. I cannot reinstall through PECL because I use the Debian standard.
phpinfo prints the following regarding oauth:
OAuth
- OAuth support | enabled
- PLAINTEXT support | enabled
- RSA-SHA1 support | enabled
- HMAC-SHA1 support | enabled
- Request engine support | php_streams
- source version | $Id$
- version | 2.0.3-dev
Solution on Debian Stretch:
You need to use PECL to reinstall oauth.so including curl support for "Request engine support". First install libcurl4-gnutls-dev:
apt install libcurl4-gnutls-dev
Without the following link, the compilation of oauth.so finishes without curl support, because curl/easy.h is not found:
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/
Finally you can install through PECL for a specific installed PHP version:
pecl -d php_suffix=7.2 install oauth
Don't forget to restart the PHP enviroment for example:
systemctl restart php7.2-fpm.service
Now phpinfo() will show:
OAuth support | enabled |
---|---|
PLAINTEXT support | enabled |
RSA-SHA1 support | enabled |
HMAC-SHA1 support | enabled |
Request engine support | php_streams, curl |
version | 2.0.4 |
Did anyone get this to work ona system that doesn't have pecl (like ubuntu)?
Quick update: I got it to work. In my case installing pecl
/pear
just didn't work fpr php 7.3.
I've now installed 7.4 from ppa:ondrej/php
and (re)installed oauth with the method above. This finally worked.
As I had to do this a couple times now on different servers, here's a "complete" guide on what to do to recompile oauth (change php version to whatever you are using):
sudo aptitude install php-pear libcurl4-gnutls-dev libpcre3-dev php7.4-dev
sudo ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/
sudo pecl -d php_suffix=7.4 install oauth
- this actually segfaulted at the end for me. But still worked
sudo systemctl restart php7.4-fpm.service
- only if you have fpm running
Just came back to this problem on Debian 11 Bullseye. I solved it vy uninstalling through pecl and installing again
pecl -d php_suffix=7.3 uninstall oauth
...
pecl -d php_suffix=7.3 install oauth
followed by recompilation.
After this, do not forget to restart the php7.3-fpm! Exchange the PHP version number for the one you need.