twitter - Tweet status and picture with PHP using TwitterAPIExchange (part 2) -
i asked question, struggling status , media upload twitter, using php , twitterapiexchange.
i given advice, still won't work. is, don't error, tweet not appear.
i thought easier write new post previous 1 not allow me add more few hundred characters.
i have re-written function (shown @ end) tweet status+image. makes shorter and, hope, simpler follow. have got rid on deprecated call, advised.
i have included dump of key variables. these come out as:
$tweet = 'test stack exchange' $imagespath = '/twitter/images/gxk/' $image = 'graham.jpg' $url = 'https://api.twitter.com/1.1/statuses/update.json' $imagetopost = '/twitter/images/gxk/graham.jpg'
i have tried putting in full path name image, is:
'media[]' => "@{http://www.graham-kendall.com/twitter/images/gxk/graham.jpg}");
i have tried:
'media' => "http://www.graham-kendall.com/twitter/images/gxk/graham.jpg");
this does tweet text not image.
any appreciated.
the function
public function postimagetweet($tweet, $imagespath, $image) { $url = $this->basetwitterurl . 'statuses/update.json'; $imagetopost = $imagespath . $image; // display key variables echo "tweet: " . $tweet . $newline; echo "imagespath: " . $imagespath . $newline; echo "image: " . $image . $newline; echo "url: " . $url . $newline; echo "imagetopost: " . $imagetopost . $newline; $requestmethod = 'post'; $postfields = array( 'status' => $tweet, 'media[]' => "@{http://www.graham-kendall.com/twitter/images/gxk/graham.jpg}"); try{ $twitter = new twitterapiexchange($this->settings); echo $twitter->buildoauth($url, $requestmethod) ->setpostfields($postfields) ->performrequest(); } catch (exception $ex) { echo $ex->getmessage(); } } // postimagetweet
i think $url
has this:
$url = $this->basetwitterurl . 'statuses/update_with_media.json';
if don't use 'with_media' won't work.
Comments
Post a Comment