Status update encoding problem (PHP and cURL) "Could not authenticate you"

php

#1

I am creating my own function for authenticating/authorizing a user and then sending a Tweet.

The frustrating thing is, the Tweet will only be created if the status text is wrapped in DOUBLE rawurlencode:

      $status = 'Hello World';

      $options = array(
         CURLOPT_HTTPHEADER => array($authHeader),
         CURLOPT_HEADER => false,
         CURLOPT_URL => $baseUri,
         CURLOPT_POST => true,
         CURLOPT_POSTFIELDS => 'status=' . rawurlencode(rawurlencode($status)),
         CURLOPT_RETURNTRANSFER => true,
         CURLOPT_VERBOSE => true,
         CURLOPT_SSL_VERIFYPEER => false
      );

The above tweets: “Hello%20World”

If I change the POSTFIELDS to be rawurlencode($status) or simply $status, the tweet fails with the following response:

object(stdClass)#21 (1) {
[“errors”] => array(1) {
[0] => object(stdClass)#94 (2) {
[“message”] => string(26) “Could not authenticate you”
[“code”] => int(32)
}
}
}

I can post the rest of my code if you like, but hopefully you can assume it’s ok on the basis that tweets are generated in some circumstances…

I’ve even tried the default output the Twitter oAuth Tool generates: Also fails :frowning:

I think this is clearly something to do with the encoding of the $status string, but I can’t see what I’m doing wrong.


#2

i’m confused… jasa seo


#3

I have having the exact same problem.

If I have a encoded status : “Hello%20Ladies%20%2b%20Gentlemen%2c%20a%20signed%20OAuth%20request%21”

It tweets it fine, but appears on my feed as “Hello%20Ladies%20%2b%20Gentlemen%2c%20a%20signed%20OAuth%20request%21”

Where as if I changed the status to : “Hello Ladies + Gentlemen, a signed OAuth request!”

I get:

{
“errors”: [
{
“code”: 32,
“message”: “Could not authenticate you.”
}
]
}

Any ideas anyone ?

Driving me crazy!!