Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to be able to update a twitter status using only functions allowed by Wordpress VIP.

I am using this library: https://github.com/Automattic/wp-codebird

Which of course is broken, any of the functions that upload an image just don't work. I already posted an issue https://github.com/Automattic/wp-codebird/issues/6

But the project is dead, I doubt any updates will ever hit it again, so I need to fix this issue myself using this old code I am forced to work with.

Basically I think I can easily fix this issue if I know what variables I need to feed wp_remote_post to update_with_media. Here is what I am currently feeding in and the responses I am receiving.

// url I am requesting
$url = 'https://api.twitter.com/1.1/statuses/update_with_media.json';

// the 2nd argument to wp_remote_post
$params = Array
(
    [method] => POST
    [timeout] => 5
    [redirection] => 5
    [httpversion] => 1.1
    [blocking] => 1
    [headers] => Array
        (
            [Authorization] => OAuth oauth_consumer_key="[MY CONSUMER KEY]", oauth_nonce="8429c5ec", oauth_signature="V3vGmKCYCp2yDjCFl5OTKzEfVlc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1385072895", oauth_token="[MY TOKEN]", oauth_version="1.0"
            [Expect] => 
            [Content-Type] => multipart/form-data
        )

    [body] => Array
        (
            [status] => Testing http://127.0.0.1:7070/?p=57
            [media[]] => @/home/dillon/Code/lib/WordPress/wp-content/uploads/2013/11/Selection_001.png
        )

    [cookies] => Array
        (
        )

    [sslverify] => 
);

// this is the object returned to me
$response = Array
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 195
                    [message] => Missing or invalid url parameter.
                )

        )

    [httpstatus] => 403
);

// this is what is returned to me if I remove the Content-Type from the header array
$response = Array
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [message] => Could not authenticate you
                    [code] => 32
                )

        )

    [httpstatus] => 403
);
share|improve this question
    
Can you successfully construct and make such request in plain PHP/curl for starters? It's pretty unspecific error response and it's hard to say is WP going wrong here or something else among all the moving parts involved. –  Rarst Nov 23 '13 at 20:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.