Abraham\TwitterOAuth\TwitterOAuth::upload PHP Method

upload() public method

Upload media to upload.twitter.com.
public upload ( string $path, array $parameters = [], boolean $chunked = false ) : array | object
$path string
$parameters array
$chunked boolean
return array | object
    public function upload($path, array $parameters = [], $chunked = false)
    {
        if ($chunked) {
            return $this->uploadMediaChunked($path, $parameters);
        } else {
            return $this->uploadMediaNotChunked($path, $parameters);
        }
    }

Usage Example

Esempio n. 1
2
 function PostImage()
 {
     if (!isset($_POST['source']) || $_POST['source'] == "") {
         return "Missing required params";
     }
     $config = (include "/config.php");
     $source = $_POST['source'];
     $final = "";
     if (isset($_POST['message'])) {
         $orig = $_POST['message'];
         $final = FilterText($orig);
     }
     $access_token = $_SESSION['access_token'];
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
     $check = new TB_Twitter_Check();
     if (!$check->VerifyTweet($source, $final)) {
         return "Tweet is not valid";
         exit;
     }
     $media1 = $connection->upload('media/upload', array('media' => $source));
     $parameters = array('status' => $final, 'media_ids' => implode(',', array($media1->media_id_string)));
     $result = $connection->post('statuses/update', $parameters);
     if ($connection->getLastHttpCode() == 200) {
         return "success";
     } else {
         return "An unnknown error occured";
     }
 }
All Usage Examples Of Abraham\TwitterOAuth\TwitterOAuth::upload