How to post with picture using tmhOAuth?


#1

Hi together,

I am currently upgrading from REST API v1 to v1.1. My login process ist already working. Now I want to create a new tweet using tmhOAuth. Here my code:

$code = $tmhOAuth->user_request(
	'POST',
	'1.1/statuses/update_with_media',
	array(
		'media[]'  => "@{/path_to_image/imagename.jpg};type=image/jpeg;filename={imagename.jpg}",
		'status'   => "Please tweet me"
  	),
	true, // use auth
	true // multipart
);
print_r($tmhOAuth->response);

Here is the response:

Array
(
	[raw] => 
[code] => 0
	[response] => 
	[info] => Array
    	(
        	[url] => HTTP://://
        	...
    	)
	[error] => Couldn't resolve host ''
	[errno] => 6
)

Can anyone help me solving the issue?

Greetings,

Tobias


#2

Basically what you’re doing to calling exactly “1.1/statuses/update_with_media” when you need to call “https://api.twitter.com/1.1/statuses/update_with_media”. Also it’s suggested to use the endpoint “statuses/update”.


#3

Hi trace,

thanks for your idea! I tried both, but it’s the same as before. Do you have any other ideas?

Greetings,

Tobias


#4

Use the new endpoint statuses/update


#6

Hi together,

I solved it.

  1. Problem: the correct endpoint ist: https://api.twitter.com/1.1/statuses/update_with_media.json

  2. Problem: this image transmission as described here: https://github.com/themattharris/tmhOAuth/issues/76.

Thanks for your patience!

Greetings,

Tobias