Skip to content

Commit

Permalink
🛠 Re-worked TwitterOAuth.php 🛠
Browse files Browse the repository at this point in the history
:octocat:
-To fill a need for conversion of media URLs to base64
(negating the need for storing the media prior to uploading)
-Added public function `shipit` that privately calls to
-Added private function `uploadMediaNotStored`
  • Loading branch information
jaechow committed Dec 18, 2021
1 parent 1560454 commit 8aa9106
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/TwitterOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,35 @@ public function mediaStatus(string $media_id)
false,
);
}

/**
* Convert a URL to media to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function shipit($path, $parameters = []) {
return $this->uploadMediaNotStored($path, $parameters);
/**
* Private method to convert a URL to media to upload.twitter.com.
*
* @param string $path
* @param array $parameters
* @param boolean $chunked
*
* @return array|object
*/
}
private function uploadMediaNotStored($path, array $parameters)
{
if (! is_readable($parameters['media']) &&
($file = file_get_contents($parameters['media'])) === false) {
throw new \InvalidArgumentException('You must supply a readable file');
}
$parameters['media'] = base64_encode($file);
return $this->http('POST', self::UPLOAD_HOST, $path, $parameters);
}
/**
* Private method to upload media (not chunked) to upload.twitter.com.
*
Expand Down

1 comment on commit 8aa9106

@jaechow
Copy link
Member Author

@jaechow jaechow commented on 8aa9106 Dec 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per issue abraham#681
Incorporated && from:
laravel-notification-channels/twitter#64

Please sign in to comment.