Advertisement:

Author Topic: twitter auto post with wrong image  (Read 72 times)

ala

  • Full Member
  • ***
  • Posts: 194
twitter auto post with wrong image
« on: July 12, 2018, 09:44:56 am »
i have been bought twister auto post  from osclass market and i don't know why now it remove from osclass. i can't contact developer  now for fix some problem.
i have problem with image, ad has been post to twitter as well but some show wrong image  like gun or drug image.
i check code on tw_post_plugin_create function and show url store image on Amazonaws.
can anyone help me how to store image in website instead of Amazonaws?

Code: [Select]
function tw_post_plugin_create($item) {
    if (!get_tw_on_create()) {
return '';
}
if (get_tw_post_categories() != 'all') {
        // Check if the item is in the categories set in the plugin.
        if (!in_array($item['fk_i_category_id'], get_tw_post_categories())) {
            return '';
        }
    }
    if (!get_tw_post_consumer_key() || !get_tw_post_consumer_secret() || !get_tw_post_access_token() || !get_tw_post_access_token_secret()) {
        return '';
    }

if (get_tw_post_message_tweet()) {

$replacements =  array(
'item_title' => osc_item_title(),
'item_description' => osc_item_description(),
'item_pub_date' => osc_item_pub_date(),
'item_price' => osc_item_price(),
'item_formated_price' => osc_item_formated_price(),
'item_region' => osc_item_region(),
'item_city' => osc_item_city(),
'item_url' => osc_item_url(),
);

$pattern = '{{%s}}';

$map = array();
foreach($replacements as $var => $value)
{
$map[sprintf($pattern, $var)] = $value;
}

$output = strtr(get_tw_post_message_tweet(), $map);
$connection = new TwitterOAuth(get_tw_post_consumer_key(),get_tw_post_consumer_secret(), get_tw_post_access_token(), get_tw_post_access_token_secret());
$parameters = array(
'status' => $output
);
osc_reset_resources();
if (get_tw_include_image() && osc_count_item_resources() > 0) {
$medias = array();
for( $i = 0; osc_has_item_resources(); $i++ ) {
if ($i >= 3 ) {
break;
}
$upload = $connection->upload('media/upload', array('media' => "https://s3.us-east-1.amazonaws.com/elasticbeanstalk-us-east-1-393378754272/".osc_resource_id().".".osc_resource_field("s_extension")));           
$medias[] = $upload->media_id_string;
}
$parameters['media_ids'] = implode(',', $medias);
}
$result = $connection->post('statuses/update', $parameters);
}
}