0

$json という名前の変数に json でエンコードされたデータがあります。

    string(1243) "{"screenShareCode":"882919360",
    "appletHtml":"",
    "presenterParams":"aUsEN5gjxX/3NMrlIEGpk0=",
    "viewerUrl":"http://api.screenleap.com/v2/viewer/882919360?accountid=mynet",
    "オリジン":"API"}"
    }

このjsonデータをjavascript関数に渡す必要があります。以下を参照してください

    script type="text/javascript" src="http://api.screenleap.com/js/screenleap.js">/script>
    スクリプト タイプ="text/javascript">
      window.onload = function() {
    var screenShareData = '?php echo $json;?>';
        screenleap.startSharing('DEFAULT', screenShareData);
      };
    /スクリプト>

このコードを実行しようとすると、「必須の画面共有データがありません」というエラーが表示されます。
このエラーを解決するにはどうすればよいですか?

i am following "https://www.screenleap.com/api/presenter"
4

3 に答える 3

0

これは、ドキュメントに基づいて実装する方法です

https://www.screenleap.com/api/presenter

<?php

// Config
$authtoken = '';
$accountid = '';

// 1. Make CURL Request
$url = 'https://api.screenleap.com/v2/screen-shares';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('authtoken:<authtoken>'));
curl_setopt($ch, CURLOPT_POSTFIELDS, 'accountid=<accountid>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data, true);

?>

<!-- 2. Launch the Presenter App -->
<script type="text/javascript" src="http://api.screenleap.com/js/screenleap.js"></script>
<script type="text/javascript">
    window.onload = function() {
        screenleap.startSharing('DEFAULT', JSON.parse('<?php echo $json; ?>'));
    };
</script>

これが機能しない場合は、スクリーンリープに報告する必要があります。

于 2013-11-12T12:23:29.247 に答える
0

値にアクセスする場合は、JSON を実際に解析するだけで済みます。それ以外の場合は、次のように、応答データを startSharing 関数にそのまま渡します。

<?php
$url = 'https://api.screenleap.com/v2/screen-shares';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('authtoken:<your authtoken>'));
curl_setopt($ch, CURLOPT_POSTFIELDS, 'accountid=<your accountid>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data, true);
?>

<script type="text/javascript" src="http://api.screenleap.com/js/screenleap.js"></script>
<script type="text/javascript">
    window.onload = function() {
        screenleap.startSharing('DEFAULT', <?php echo $data; ?>);
    };
</script>

独自の accountid と authtoken を (先頭のスペースなしで) 挿入するだけで、うまくいくはずです。

于 2013-11-14T00:20:12.267 に答える