I'm really not enjoying the documentation for the Twitter API... There doesn't appear to be too much support for it either. I've managed to get it working posting simple status updates, but can't seem to get posting images to work. Here is what I have thus far: <?php require 'tmhOAuth.php'; require 'tmhUtilities.php'; $tmhOAuth = new tmhOAuth(array( 'consumer_key' => '', 'consumer_secret' => '', 'user_token' => '', 'user_secret' => '', )); $image = 'http://localhost/api/twitter/oAuth/test.jpg'; $code = $tmhOAuth->request( 'post', 'https://api.twitter.com/1.1/statuses/update_with_media.json', array( 'media[]' => "@{$image};type=image/jpeg;filename={$image}", 'status' => 'Picture time' ), true, true ); //var_dump($tmhOAuth->response); if ($code == 200) { tmhUtilities::pr(json_decode($tmhOAuth->response['response'])); } else { tmhUtilities::pr($tmhOAuth->response['response']); } ?> PHP: All I seem to get is Reading up on what this means but seem to be getting mixed messages everything from incorrect tokens to 401? Any advise?
Got this working with the following amendment: <?php require 'tmhOAuth.php'; require 'tmhUtilities.php'; $tmhOAuth = new tmhOAuth(array( 'consumer_key' => '', 'consumer_secret' => '', 'user_token' => '', 'user_secret' => '', 'curl_ssl_verifypeer' => false )); $image_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test.jpg'; $name = basename($image_path); $code = $tmhOAuth->request( 'POST', $tmhOAuth->url('1.1/statuses/update_with_media'), array( 'media[]' => "@{$image_path};type=image/jpeg;filename={$name}", 'status' => 'Picture time', ), true, // use auth true // multipart ); if ($code == 200) { tmhUtilities::pr(json_decode($tmhOAuth->response['response'])); } else { tmhUtilities::pr($tmhOAuth->response['response']); } ?> PHP:
Sorry I don't understand? The above script is just the Twitter post part of a news article with image upload from form...