Git Product home page Git Product logo

Comments (14)

zx1986 avatar zx1986 commented on July 25, 2024

I added $dbh->exec("set names utf8"); in PDO, and got:

    [message] => ��快��
��快��
��快��
��快��

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

is your database UTF-8 enabled?

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

Yes, I can replicate this issue. I will see if I can do something about it

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

Remove the "utf8_encode" on this line, and it should work.

https://github.com/phpList/phplist-plugin-restapi/blob/master/plugins/restapi/includes/response.php#L69

Change the line to

                $result[$key] = $value;

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

michield@3ad5878

from phplist-plugin-restapi.

zx1986 avatar zx1986 commented on July 25, 2024

I patch it, but still not work.
I am pretty sure the data is UTF-8 in my database.
Because it works fine and show correctly in PHPList.

I am add a function in phpListRESTApiClient.php to test it:

+     public function campaignGet($camp_id)
+     {
+       $post_params = array( 'id' => $camp_id );
+       $result = $this->callAPI('campaignGet', $post_params);
+       return $result;
+     }

And I got the JSON:

id: "2",
subject: "???? ~",
fromfield: "[email protected]",
tofield: "",
replyto: "",
message: "????? ?????",
textmessage: "",
footer: "",
entered: "2015-09-17 09:29:20",
modified: "2015-11-24 22:33:24",

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

Hmm, that's strange. I added a unit test, which passes: https://github.com/michield/phplist-plugin-restapi/blob/master/tests/phpunit/restapi.php#L711

I will try to see how it is when the text is added in phpList and consumed from the API

from phplist-plugin-restapi.

zx1986 avatar zx1986 commented on July 25, 2024

I'm running in a Docker.
I check my config, and I found my apache startup script:

#!/bin/sh
TZ=MET-1METDST
export TZ
exec /usr/sbin/apache2ctl -DNO_DETACH

I will remove TZ=MET-1METDST and test again.
the same error.

My Dockerfile:

FROM phusion/baseimage:0.9.17
CMD ["/sbin/my_init"]

RUN ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
RUN echo "Asia/Taipei" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get update && apt-get install -y \
    apache2 libapache2-mod-php5 \
    php5-cli php5-curl php5-mysql php5-mcrypt php5-json php5-gd php5-mysql php-mail \
    sendmail

# Running additional deamons
RUN mkdir -p /etc/service/httpd/
ADD Dockerconfig/httpd.sh /etc/service/httpd/run
RUN chmod -R 755 /etc/service/

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

from phplist-plugin-restapi.

zx1986 avatar zx1986 commented on July 25, 2024

I will try to your testing, and check my env again, then try again.
Thank your for help!

from phplist-plugin-restapi.

zx1986 avatar zx1986 commented on July 25, 2024

Hello! @michield
My college found that:

--- a/lists/admin/plugins/restapi/includes/pdo.php
+++ b/lists/admin/plugins/restapi/includes/pdo.php
@@ -15,7 +15,7 @@ class PDO extends \PDO
         $dbuser = $GLOBALS['database_user'];
         $dbpass = $GLOBALS['database_password'];
         $dbname = $GLOBALS['database_name'];
-        $dbh = new \PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
+        $dbh = new \PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

And it works.

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

great, thanks

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

Are you using phpList? Would be cool to update the translation, https://translate.phplist.org/zh_TW/

:hint: :-)

from phplist-plugin-restapi.

michield avatar michield commented on July 25, 2024

#24

from phplist-plugin-restapi.

zx1986 avatar zx1986 commented on July 25, 2024

sure!
I will do the translate on this weekend :-)

from phplist-plugin-restapi.

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.