twitter - Tweet status and picture with PHP using TwitterAPIExchange -


i have written following php function (see below) allows me tweet either staus or status+image.

the status update works fine, if pass image name (and fact strlen($image) !=0 dictates different path through function), not tweet, nor error.

i have tried manually putting image path+name 'media[]' element of array, cannot work.

i have tried

'media[]' => "http://www.website.com/twitter/images/pic.jpg"); 

... full path name file, suggested in previous post. give me error:

{"errors":[{"code":189,"message":"error creating status."}]}

i have followed few other forum posts, after couple of days getting little frustrated? :-).

any appreciated.

public function posttweet($tweet, $imagespath, $image) { $url      = $this->basetwitterurl . 'statuses/update.json'; $urlmedia = $this->basetwitterurl . 'statuses/update_with_media.json';  $posturl = "";  $requestmethod = 'post';  if(strlen($image) == 0) {    $postfields = array(    'status' => $tweet);      $posturl = $url; } else {     $imagetopost = $imagespath . $image;     $postfields = array(       'status' => $tweet,       'media[]' => "@{$imagetopost}");     $posturl = $urlmedia; };  try{            $twitter = new twitterapiexchange($this->settings);    $postfields[status] . $this->newline;     echo $twitter->buildoauth($posturl, $requestmethod)                 ->setpostfields($postfields)                 ->performrequest();     } catch (exception $ex) {         echo $ex->getmessage();    } } // posttweet 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -