Twitter tmhOAuth - problems uploading image to user page -


i using tmhoauth https://github.com/themattharris/tmhoauth, , trying upload image website user's twitter page. response on callback.php 200 (success), there nothing on user's page. app has r/w permissions, , "allow application used sign in twitter" checked. has idea? using 2 php files:

twitter.php

include("tmhoauth.php"); include("tmhutilities.php"); $tmhoauth = new tmhoauth(array( 'consumer_key' => 'abcd123', 'consumer_secret' => 'xyz', 'curl_ssl_verifypeer' => false )); $tmhoauth->request('post', $tmhoauth->url('oauth/request_token', '')); $response = $tmhoauth->extract_params($tmhoauth->response["response"]); $temp_token = $response['oauth_token'];  $temp_secret = $response['oauth_token_secret'];  $time = $_server['request_time']; setcookie("temp_token", $temp_token, $time + 3600 * 30, '/'); setcookie("temp_secret", $temp_secret, $time + 3600 * 30, '/'); setcookie("tweet_txt", 'share afa stand!', $time + 3600 * 30, '/'); setcookie("img_url", 'success', $time + 3600 * 30, '/'); $url = $tmhoauth->url("oauth/authorize", "") . '?oauth_token=' . $temp_token; echo '<a href="'.$url.'">post image on twitter</a>'; 

callback.php

define("consumer_key", "abcd123"); define("consumer_secret", "xyz"); include("tmhoauth.php"); include("tmhutilities.php"); $token = $_cookie['temp_token']; $secret = $_cookie['temp_secret']; $txt = $_cookie['tweet_txt']; $img = base64_encode(file_get_contents('wide/achievement.jpg')); $tmhoauth = new tmhoauth(array( 'consumer_key' => consumer_key, 'consumer_secret' => consumer_secret, 'user_token' => $token, 'user_secret' => $secret,  'curl_ssl_verifypeer' => false )); $tmhoauth->request("post", $tmhoauth->url("oauth/access_token", ""), array(       'oauth_verifier' => $_get["oauth_verifier"]  ));  $response = $tmhoauth->extract_params($tmhoauth->response["response"]); $tmhoauth->config["user_token"] = $response['oauth_token'];  $tmhoauth->config["user_secret"] = $response['oauth_token_secret'];  $code = $tmhoauth->request('post', 'https://upload.twitter.com/1.1/media/upload.json', array(     'media_data' => $img,     'status' => $txt ), true, // use auth true // multipart ); if ($code == 200){     echo '<h1>your image tweet has been sent successfully</h1>'; }else{     echo $code;     echo "failed<br />";     tmhutilities::pr($tmhoauth->response['response']); } 

i getting "your image tweet has been sent successfully", not posted. please help.

figured out. had change api url to: https://api.twitter.com/1.1/statuses/update_with_media.json


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -