*/
function twitter_do_mirrorpost(App $a, $uid, $post)
{
+ $datarray['uid'] = $uid;
$datarray['extid'] = 'twitter::' . $post->id;
$datarray['title'] = '';
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
+ // Ensure to have the own contact
+ try {
+ twitter_fetch_own_contact($a, $uid);
+ } catch (TwitterOAuthException $e) {
+ Logger::warning('Error fetching own contact', ['uid' => $uid, 'message' => $e->getMessage()]);
+ return;
+ }
+
$parameters = ["exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended", "include_ext_alt_text" => true];
$first_time = ($lastid == "");
if (!empty($cid)) {
DBA::update('contact', $fields, ['id' => $cid]);
Contact::updateAvatar($cid, $avatar);
+ } else {
+ Logger::warning('No contact found', ['fields' => $fields]);
}
$contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
- if (!DBA::isResult($contact) && !$create_user) {
+ if (!DBA::isResult($contact) && empty($cid)) {
Logger::warning('User contact not found', ['uid' => $uid, 'twitter-id' => $data->id_str]);
return 0;
+ } else {
+ return $cid;
}
if (!DBA::isResult($contact)) {