problem with upload image

coedin
@coedin coedin
  1. $twitteroauth = $in2social->TwitterOAuth($token['oauth_token'],$token['oauth_secret']);            
  2.            /*  $twitter = $twitteroauth->post('statuses/update', array(
  3.                                                   'status' => $message
  4.                                                   ));  
  5.                         */
  6.  
  7.            $twitter = $twitteroauth->post('statuses/update_with_media.json', array(
  8.                                                   'status' => $message ,
  9.                                                                                                          '@media[]' => "@{$image}"
  10.                                                   ));   

i 'am post with this funnction but the image/status not post . in script commad i am use this script this message post in twitter
why update_with_media.json not function ??

1 year 48 weeks ago

Replies

episod
@episod Taylor Singletary

Do you know if the library you're using is "magically" aware that statuses/update_with_media.json is on upload.twitter.com and not api.twitter.com?

1 year 48 weeks ago
coedin
@coedin coedin

i' am use TwitterOAuth by Abraham Williams – a Twitter API library
in file twitteroauth.php i'am set
/* Set up the API root URL */
public $host = "https://api.twitter.com/1/";
to
public $host = "https://upload.twitter.com/1/";

but it not use ??

1 year 48 weeks ago
episod
@episod Taylor Singletary

That would likely change what's considered the primary API host throughout the library -- you just want it scoped for this method. I believe that twitteroauth allows you to specify a fully qualified URL on a per-method basis:

$twitteroauth->post('https://upload.twitter.com/1/statuses/update_with_media.json', ...) may get you where you need to go. That said, I'm not sure how well the library is prepared to handle multipart OAuth like this.

1 year 48 weeks ago
Samer_Melhem
@Samer_Melhem Samer Melhem

if you want to tweet images using twitter api you can check our blog to see all the steps and download the example:
http://www.stirring-interactive.com/blog/tweet-images-using-twitter-api/

42 weeks 3 days ago
RThaveesha
@RThaveesha Ravindu thaveesha

hi i did it using i did it using TwitterOAuth by Abraham Williams modified library

---html---

<form action="" method="POST" enctype="multipart/form-data">
<div>
<label for="status">Tweet Text</label>
<textarea type="text" name="status" rows="5" cols="60"></textarea>
<br />

<label for="image">Photo</label>
<input type="file" name="image" />
<br />
<input type="submit" value="Submit" />
</div>
</form>

---php---

if (!empty($_FILES)) {
// we set the type and filename are set here as well
$params = array(
'media[]' => "@{$_FILES['image']['tmp_name']};type={$_FILES['image']['type']};filename={$_FILES['image']['name']}",
'status' => $_POST['status']
);

$dd = $twitteroauth->post('statuses/update_with_media',$params,true);

var_dump($dd);
}

download modified library here

https://github.com/tomi-heiskanen/twitteroauth/blob/77795ff40e4ec914bab4604e7063fa70a27077d4/twitteroauth/twitteroauth.php

15 weeks 4 days ago
fiza51852756
@fiza51852756 fiza

@RThaveesha in require which library i should use?

12 weeks 6 days ago