本文整理匯總了PHP中Twitter::uploadMedia方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::uploadMedia方法的具體用法?PHP Twitter::uploadMedia怎麽用?PHP Twitter::uploadMedia使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::uploadMedia方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: function
*/
Route::get('/', function () {
return view('home');
});
Route::post('fetch', function () {
require_once 'app/Classes/OpenGraph.php';
$graph = OpenGraph::fetch(Input::get('url'));
foreach ($graph as $key => $value) {
$output[$key] = $value;
}
return $output;
});
Route::post('sendtweet', function () {
$file = file_get_contents(Input::get('image'));
$file = base64_encode($file);
$uploaded_media = Twitter::uploadMedia(['media_data' => $file]);
return Twitter::postTweet(['status' => Input::get('text'), 'media_ids' => $uploaded_media->media_id_string]);
});
Route::get('twitter/login', ['as' => 'twitter.login', function () {
// your SIGN IN WITH TWITTER button should point to this route
$sign_in_twitter = true;
$force_login = false;
// Make sure we make this request w/o tokens, overwrite the default values in case of login.
Twitter::reconfig(['token' => '', 'secret' => '']);
$token = Twitter::getRequestToken(route('twitter.callback'));
if (isset($token['oauth_token_secret'])) {
$url = Twitter::getAuthorizeURL($token, $sign_in_twitter, $force_login);
Session::put('oauth_state', 'start');
Session::put('oauth_request_token', $token['oauth_token']);
Session::put('oauth_request_token_secret', $token['oauth_token_secret']);
return Redirect::to($url);
示例2: tweet
/**
* Post article to twitter with cover image
*
* @param $article
* @return void
*/
private function tweet($article)
{
Tweet::reconfig(['token' => Auth::user()->twitter_token->token, 'secret' => Auth::user()->twitter_token->secret]);
$media = Tweet::uploadMedia(['media' => file_get_contents($article->cover()->url)]);
Tweet::postTweet(['status' => $article->title . ' ' . url($article->slug), 'media_ids' => $media->media_id_string]);
}