PHP Classes

Encoding error with ' in twitter

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Encoding error with ' in twitter  >  (Un) Subscribe thread alerts  
Subject:Encoding error with ' in twitter
Summary:Posting to twitter fails on ' (single quote) character
Messages:5
Author:Thijs Van der Schaeghe
Date:2013-08-19 17:36:50
Update:2013-08-22 07:17:39
 

  1. Encoding error with ' in twitter   Reply   Report abuse  
Picture of Thijs Van der Schaeghe Thijs Van der Schaeghe - 2013-08-19 17:36:50
Hi,

First things first, great library.

However, I seem to have issues posting to twitter when posting a single quote character in the message.

I've checked your encoding and it seems fine (rawurlencode with + and ~ ignored).

Maybe you know a solution?

Thanks,
Thijs

  2. Re: Encoding error with ' in twitter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-08-19 20:32:29 - In reply to message 1 from Thijs Van der Schaeghe
Can you provide a example of an API call that fails?

  3. Re: Encoding error with ' in twitter   Reply   Report abuse  
Picture of Thijs Van der Schaeghe Thijs Van der Schaeghe - 2013-08-20 08:36:18 - In reply to message 2 from Manuel Lemos
Hi Manuel,

After some more testing I have realised that it seems to work fine on my developer machine (PHP 5.4.9), but it does not work on our production machine (PHP 5.3.23).

For easy testing, I isolated part of the code:
pastebin.com/G1CRZdAW

I've skipped the whole authentication part, but the tokens I enter are valid and work for any message that does not contain a '.

According to the php manual, not much changed to rawurlencode since 5.3.23; the tilde character is no longer encoded, but you fixed that anyway.

Is there any other feature of php that could have changed that I need to take a look at?

Many thanks,
Thijs

  4. Re: Encoding error with ' in twitter   Reply   Report abuse  
Picture of Thijs Van der Schaeghe Thijs Van der Schaeghe - 2013-08-20 08:59:34 - In reply to message 3 from Thijs Van der Schaeghe
This is, of course, the output of said script on our production server.

bool(false)
object(stdClass)#13 (1) {
["errors"]=>
array(1) {
[0]=>
object(stdClass)#14 (2) {
["message"]=>
string(26) "Could not authenticate you"
["code"]=>
int(32)
}
}
}

  5. Re: Encoding error with ' in twitter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-08-22 07:17:39 - In reply to message 3 from Thijs Van der Schaeghe
I tried it here and it works with PHP 5.3.17.

I wonder if it is not a matter of encoding. Twitter API expects text already in UTF-8.