<?php

$conv_fields = array();
$conv_fields['message_id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$conv_fields['text'] = isset($_REQUEST['text']) ? _escape($_REQUEST['text']) : '';
$conv_fields['sender'] = isset($_REQUEST['sender']) ? $_REQUEST['sender'] : '';
$conv_fields['sender_last10'] = isset($_REQUEST['sender']) ? last10Char($_REQUEST['sender']) : '';
$last_conv = qs("select * from text_conversation where receiver_last10='{$conv_fields['sender_last10']}' order by id desc limit 0,1");
$conv_fields['deal_id'] = isset($last_conv['deal_id']) ? $last_conv['deal_id'] : "-";
$conv_fields['type'] = 'RECEIVED';
$conv_fields['messageTime'] = _mysqlDate();
$conv_fields['receiver'] = isset($_REQUEST['receiver']) ? $_REQUEST['receiver'] : '';
$conv_fields['receiver_last10'] = isset($_REQUEST['receiver']) ? last10Char($_REQUEST['receiver']) : '';
qi("text_conversation", $conv_fields);
die;
$person_id = $data['current']['person_id'];
$person_data = $apiPD->getPersonInfo($person_id);
$person_data = json_decode($person_data, true);
$message = $data['current']['note'];
$deal_id = $data['current']['deal_id'];
$org_id = $data['current']['org_id'];
$subject = $data['current']['subject'];
$subject = preg_replace("/[^0-9]/", "", $subject);
$activityLogArray = array();
if (strlen($subject) < 10) {
    $phone_value = isset($person_data['data']['phone'][0]['value']) ? $person_data['data']['phone'][0]['value'] : '-1';
} else {
    $phone_value = $subject;
    $activityLogArray['number_from_subject'] = '1';
}
$activityLogArray['payload'] = $payload;
$activityLogArray['activity_id'] = $activity_id;
$activityLogArray['person_id'] = $person_id;
$activityLogArray['deal_id'] = $deal_id;
$activityLogArray['org_id'] = $org_id;
if ($phone_value == '-1' || $phone_value == '') {
    $activityLogArray['log'] = "Phone value is blank";
    qi('activity_log', $activityLogArray);
} else {
    $activityLogArray['log'] = "Message sending on " . $phone_value;
    $activityLogArray['phone_value'] = $phone_value = $apiCall->ValidateNumber($phone_value);
    $activityLogArray['phone_last10'] = last10Char($phone_value);
    qi('activity_log', $activityLogArray);
    $apiCall->messageNow($phone_value, $message);
}
die;
    $api = new TextMagicAPI(array("username" => "davejay", "password" => "uUXgZoOkpG"));
    $text = _escape($_REQUEST['txtMessage']);
    $phones = array($_REQUEST['ddlPhone']);
    $results = $api->send($text, $phones, true);
    $messageId = '';
    $phone = '';
    if (isset($results['messages'])) {
        foreach ($results['messages'] as $key => $value) {
            $messageId = $key;
            $phone = $value;
        }
        $conv_fields = array();
        $conv_fields['deal_id'] = $_REQUEST['hidDealId'];
        $conv_fields['message_id'] = $messageId;
        $conv_fields['receiver'] = $phone;
        $conv_fields['receiver_last10'] = last10Char($phone);
        $conv_fields['type'] = 'SENT';
        $conv_fields['text'] = $results['sent_text'];
        $conv_fields['messageTime'] = _mysqlDate();
        $text_conv_list = q("select id from text_conversation where message_id='{$messageId}'");
        if (count($text_conv_list) == 0) {
            qi("text_conversation", $conv_fields);
        } else {
            qu("text_conversation", $conv_fields, "message_id='{$messageId}'");
        }
    }
    echo "success";
    die;
}
if (isset($_REQUEST['conv_list'])) {
    $dealId = $_REQUEST['dealId'];
Exemplo n.º 4
0
<?php

//Test Mode - Live Server Comment following 2 line.
//$_REQUEST['From']="+918460422312";
//$_REQUEST['Body']="Test Static Data";
$apiPD = new apiPipeDrive();
$apiCall = new apiCall();
$phone_value = urldecode($_REQUEST['From']);
$phone_value = last10Char($phone_value);
$payload = file_get_contents('php://input');
$activity_data = qs("select * from activity_log where phone_last10 like '%{$phone_value}%' order by id desc");
if (isset($activity_data)) {
    $fields['subject'] = 'SMS - Replied By Customer';
    $fields['done'] = '1';
    $fields['type'] = 'text';
    $fields['deal_id'] = $activity_data['deal_id'];
    // Test Deal Id - $fields['deal_id'] = '4586';
    $fields['person_id'] = $activity_data['person_id'];
    $fields['org_id'] = $activity_data['org_id'];
    $fields['note'] = _escape(urldecode($_REQUEST['Body']));
    $data = $apiPD->createActivity($fields);
    qi('test', array('payload' => $data));
}
qi('test', array('payload' => $payload, 't' => $_REQUEST['From']));
die;