dongtanjian9310 2016-05-18 16:29
浏览 55
已采纳

单击以从应用程序调用OpenVBX

I am trying to POST two pieces of data from an external webapp to OpenVBX.

calltonum:(phone number in format +12345678902)
callfromnum:(phone number in format +12345678902)

Once the data is in the app I am trying to use this feature: http://www.openvbx.org/docs/browserphone/api/

OpenVBX.clientDial({
    'to': calltonum,
    'callerid': callfromnum
});

I have verified this Javascript function works from a plugin, but havent been able to successfully post the data to a plugin yet. I was originally afraid I would run into authentication issues, but quickly found if I have an open session already and post data directly to a function inside a custom controller with a class that extends the User_Controller... It receives the post data and passes it to the view just fine.

Right now, my issue is that when I load the view it populates great with all the CSS and Javascript and data view-able on the screen but then the page requests '/' to load which redirects the browser to /messages/inbox. I am also getting a js error:

Uncaught ReferenceError: $ is not defined(anonymous function) @ dosomethingplease:116

When trying to use the browserphone api leading me to believe jquery hasnt been loaded in the template.

Here is the code I currently have:

dialbrowser.php created in /controllers

<?php 

class dialbrowserException extends Exception {}

class dialbrowser extends User_Controller {
public function __construct()
{
    parent::__construct();  
}
public function index()
{
    return $this->dosomethingplease();
}
public function dosomethingplease()
{
    $data = $this->init_view_data();
    $this->template->add_js('assets/j/plugins/call-and-sms-dialogs.js');
    $this->template->add_js('assets/j/frameworks/jquery-1.6.2.min.js');
    $data = array('calltonum' => $this->input->post('calltonum'), 'callfromnum' => $this->input->post('callfromnum'));

    $this->respond('title','dialnow', $data);
}    
}

?>

dialnow.php created in /views

<div class="vbx-content-main">

<div class="vbx-content-menu vbx-content-menu-top">
    <h2 class="vbx-content-heading">Test-a-roo</h2>
</div><!-- .vbx-content-menu -->

<div class="vbx-content-container">
    <div class="vbx-content-section">
        <div class="vbx-form">
            <h3>Receipt of Number passed:</h3>
                <div>
                    And here we made it the whole way.... didnt think we could do it huh? 
                    <?php 
                    echo "lets do this for sanity's sake... to: ".$calltonum." and from: ".$callfromnum." ...see no issues with the data!";
                    $html = "<script> $('document').ready(function(){OpenVBX.clientDial({'to': '".$calltonum."', 'callerid': '".$callfromnum."'});}); </script>";
                    echo $html;
                    ?>
                </div>
        </div>
    </div><!-- .vbx-content-section -->
</div><!-- .vbx-content-container -->

</div><!-- .vbx-content-main -->

and I can currently post to /dialbrowser/index or /dialbrowser/dosomethingplease successfully, and the data populates in the view.

What I don't understand is, why is it redirecting? And, since I am extending the User_Controller shouldnt all the critical jquery/javascript already be loaded successfully?

UPDATE: I changed $route['dialbrowser'] = "dialbrowser"; in /config/routes.php. It doesnt redirect at the controller level now! Now I can see the left menu is not there, the call button has no functionality, and the previous javascript error still persists.

  • 写回答

2条回答 默认 最新

  • doukui7574 2016-06-14 08:56
    关注

    Is this what you're looking for? There's a concept plugin to add click to call to Openvbx, but you need to modify a few lines to disable security on posting to plug-ins without authorization. https://github.com/twilio/OpenVBX/wiki/Plugin-Click-to-Flow

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测