• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP oembed_fetch_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中oembed_fetch_url函数的典型用法代码示例。如果您正苦于以下问题:PHP oembed_fetch_url函数的具体用法?PHP oembed_fetch_url怎么用?PHP oembed_fetch_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了oembed_fetch_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: oembed_replacecb

/** @file */
function oembed_replacecb($matches)
{
    $embedurl = $matches[1];
    $j = oembed_fetch_url($embedurl);
    $s = oembed_format_object($j);
    return $s;
}
开发者ID:Mauru,项目名称:red,代码行数:8,代码来源:oembed.php


示例2: oembed_replacecb

function oembed_replacecb($matches)
{
    //	logger('oembedcb');
    $embedurl = $matches[1];
    $j = oembed_fetch_url($embedurl);
    $s = oembed_format_object($j);
    return $s;
    //oembed_iframe($s,$j->width,$j->height);
}
开发者ID:vinzv,项目名称:friendica,代码行数:9,代码来源:oembed.php


示例3: nakedoembed

function nakedoembed($match)
{
    $url = count($match) == 2 ? $match[1] : $match[2];
    $o = oembed_fetch_url($url);
    if ($o['type'] == 'error') {
        return $match[0];
    }
    return '[embed]' . $url . '[/embed]';
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:9,代码来源:bbcode.php


示例4: oembed_process

function oembed_process($url)
{
    $j = oembed_fetch_url($url);
    logger('oembed_process: ' . print_r($j, true));
    if ($j && $j->type !== 'error') {
        return '[embed]' . $url . '[/embed]';
    }
    return false;
}
开发者ID:royalterra,项目名称:hubzilla,代码行数:9,代码来源:oembed.php


示例5: tryoembed

function tryoembed($match)
{
    $url = count($match) == 2 ? $match[1] : $match[2];
    $o = oembed_fetch_url($url);
    if ($o->type == 'error') {
        return $match[0];
    }
    $html = oembed_format_object($o);
    return $html;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:10,代码来源:bbcode.php


示例6: oembed_content

function oembed_content(&$a)
{
    if ($a->argc == 2) {
        echo "<html><body>";
        $url = base64url_decode($a->argv[1]);
        $j = oembed_fetch_url($url);
        echo $j->html;
        echo "</body></html>";
    }
    killme();
}
开发者ID:nphyx,项目名称:friendica,代码行数:11,代码来源:oembed.php


示例7: oembed_init

function oembed_init(&$a)
{
    // logger('mod_oembed ' . $a->query_string, LOGGER_ALL);
    if (argc() > 1) {
        if (argv(1) == 'b2h') {
            $url = array("", trim(hex2bin($_REQUEST['url'])));
            echo oembed_replacecb($url);
            killme();
        } elseif (argv(1) == 'h2b') {
            $text = trim(hex2bin($_REQUEST['text']));
            echo oembed_html2bbcode($text);
            killme();
        } else {
            echo "<html><body>";
            $j = oembed_fetch_url(base64url_decode(argv(1)));
            echo $j->html;
            //		    logger('mod-oembed ' . $j->html, LOGGER_ALL);
            echo "</body></html>";
        }
    }
    killme();
}
开发者ID:Mauru,项目名称:red,代码行数:22,代码来源:oembed.php


示例8: init

 function init()
 {
     // logger('mod_oembed ' . \App::$query_string, LOGGER_ALL);
     if (argc() > 1) {
         if (argv(1) == 'b2h') {
             $url = array("", trim(hex2bin($_REQUEST['url'])));
             echo oembed_replacecb($url);
             killme();
         } elseif (argv(1) == 'h2b') {
             $text = trim(hex2bin($_REQUEST['text']));
             echo oembed_html2bbcode($text);
             killme();
         } else {
             echo "<html><head><base target=\"_blank\" /></head><body>";
             $src = base64url_decode(argv(1));
             $j = oembed_fetch_url($src);
             echo $j['html'];
             //		    logger('mod-oembed ' . $h, LOGGER_ALL);
             echo "</body></html>";
         }
     }
     killme();
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:23,代码来源:Oembed.php


示例9: oembed_content

function oembed_content(&$a)
{
    // logger('mod_oembed ' . $a->query_string, LOGGER_ALL);
    if ($a->argv[1] == 'b2h') {
        $url = array("", trim(hex2bin($_REQUEST['url'])));
        echo oembed_replacecb($url);
        killme();
    }
    if ($a->argv[1] == 'h2b') {
        $text = trim(hex2bin($_REQUEST['text']));
        echo oembed_html2bbcode($text);
        killme();
    }
    if ($a->argc == 2) {
        echo "<html><body>";
        $url = base64url_decode($a->argv[1]);
        $j = oembed_fetch_url($url);
        echo $j->html;
        //		logger('mod-oembed ' . $j->html, LOGGER_ALL);
        echo "</body></html>";
    }
    killme();
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:23,代码来源:oembed.php


示例10: tryoembed

function tryoembed($match)
{
    //$url = ((count($match)==2)?$match[1]:$match[2]);
    $url = $match[1];
    // Always embed the SSL version
    $url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"), array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
    //logger("tryoembed: $url");
    $o = oembed_fetch_url($url);
    if (isset($match[2])) {
        $o->title = $match[2];
    }
    if ($o->type == "error") {
        return $match[0];
    }
    $html = oembed_format_object($o);
    return $html;
    //oembed_iframe($html,$o->width,$o->height);
}
开发者ID:vinzv,项目名称:friendica,代码行数:18,代码来源:bbcode.php


示例11: parseurl_getsiteinfo

function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1)
{
    require_once "include/network.php";
    $a = get_app();
    $siteinfo = array();
    if ($count > 10) {
        logger("parseurl_getsiteinfo: Endless loop detected for " . $url, LOGGER_DEBUG);
        return $siteinfo;
    }
    $url = trim($url, "'");
    $url = trim($url, '"');
    $url = original_url($url);
    $siteinfo["url"] = $url;
    $siteinfo["type"] = "link";
    $stamp1 = microtime(true);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
    $header = curl_exec($ch);
    $curl_info = @curl_getinfo($ch);
    $http_code = $curl_info['http_code'];
    curl_close($ch);
    $a->save_timestamp($stamp1, "network");
    if (($curl_info['http_code'] == "301" or $curl_info['http_code'] == "302" or $curl_info['http_code'] == "303" or $curl_info['http_code'] == "307") and ($curl_info['redirect_url'] != "" or $curl_info['location'] != "")) {
        if ($curl_info['redirect_url'] != "") {
            $siteinfo = parseurl_getsiteinfo($curl_info['redirect_url'], $no_guessing, $do_oembed, ++$count);
        } else {
            $siteinfo = parseurl_getsiteinfo($curl_info['location'], $no_guessing, $do_oembed, ++$count);
        }
        return $siteinfo;
    }
    // if the file is too large then exit
    if ($curl_info["download_content_length"] > 1000000) {
        return $siteinfo;
    }
    // if it isn't a HTML file then exit
    if ($curl_info["content_type"] != "" and !strstr(strtolower($curl_info["content_type"]), "html")) {
        return $siteinfo;
    }
    if ($do_oembed) {
        require_once "include/oembed.php";
        $oembed_data = oembed_fetch_url($url);
        if ($oembed_data->type != "error") {
            $siteinfo["type"] = $oembed_data->type;
        }
        if ($oembed_data->type == "link" and $siteinfo["type"] != "photo") {
            if (isset($oembed_data->title)) {
                $siteinfo["title"] = $oembed_data->title;
            }
            if (isset($oembed_data->description)) {
                $siteinfo["text"] = trim($oembed_data->description);
            }
            if (isset($oembed_data->thumbnail_url)) {
                $siteinfo["image"] = $oembed_data->thumbnail_url;
            }
        }
    }
    $stamp1 = microtime(true);
    // Now fetch the body as well
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
    $header = curl_exec($ch);
    $curl_info = @curl_getinfo($ch);
    $http_code = $curl_info['http_code'];
    curl_close($ch);
    $a->save_timestamp($stamp1, "network");
    // Fetch the first mentioned charset. Can be in body or header
    $charset = "";
    if (preg_match('/charset=(.*?)[' . "'" . '"\\s\\n]/', $header, $matches)) {
        $charset = trim(trim(trim(array_pop($matches)), ';,'));
    }
    if ($charset == "") {
        $charset = "utf-8";
    }
    $pos = strpos($header, "\r\n\r\n");
    if ($pos) {
        $body = trim(substr($header, $pos));
    } else {
        $body = $header;
    }
    if ($charset != '' and strtoupper($charset) != "UTF-8") {
        logger("parseurl_getsiteinfo: detected charset " . $charset, LOGGER_DEBUG);
        //$body = mb_convert_encoding($body, "UTF-8", $charset);
        $body = iconv($charset, "UTF-8//TRANSLIT", $body);
    }
    $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
    $doc = new DOMDocument();
    @$doc->loadHTML($body);
    deletenode($doc, 'style');
    deletenode($doc, 'script');
//.........这里部分代码省略.........
开发者ID:rahmiyildiz,项目名称:friendica,代码行数:101,代码来源:parse_url.php


示例12: twitter_expand_entities

function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontincludemedia)
{
    require_once "include/oembed.php";
    $tags = "";
    if (isset($item->entities->urls)) {
        $type = "";
        $footerurl = "";
        $footerlink = "";
        $footer = "";
        foreach ($item->entities->urls as $url) {
            if ($url->url and $url->expanded_url and $url->display_url) {
                $expanded_url = twitter_original_url($url->expanded_url);
                $oembed_data = oembed_fetch_url($expanded_url);
                // Quickfix: Workaround for URL with "[" and "]" in it
                if (strpos($expanded_url, "[") or strpos($expanded_url, "]")) {
                    $expanded_url = $url->url;
                }
                if ($type == "") {
                    $type = $oembed_data->type;
                }
                if ($oembed_data->type == "video") {
                    $body = str_replace($url->url, "[video]" . $expanded_url . "[/video]", $body);
                    $dontincludemedia = true;
                } elseif ($oembed_data->type == "photo" and isset($oembed_data->url) and !$dontincludemedia) {
                    $body = str_replace($url->url, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body);
                    $dontincludemedia = true;
                } elseif ($oembed_data->type != "link") {
                    $body = str_replace($url->url, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
                } else {
                    $img_str = fetch_url($expanded_url, true, $redirects, 4);
                    $tempfile = tempnam(get_config("system", "temppath"), "cache");
                    file_put_contents($tempfile, $img_str);
                    $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                    unlink($tempfile);
                    if (substr($mime, 0, 6) == "image/") {
                        $type = "photo";
                        $body = str_replace($url->url, "[img]" . $expanded_url . "[/img]", $body);
                        $dontincludemedia = true;
                    } else {
                        $type = $oembed_data->type;
                        $footerurl = $expanded_url;
                        $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
                        //$footerlink = "[url=".$expanded_url."]".$url->display_url."[/url]";
                        $body = str_replace($url->url, $footerlink, $body);
                    }
                }
            }
        }
        if ($footerurl != "") {
            $footer = twitter_siteinfo($footerurl, $dontincludemedia);
        }
        if ($footerlink != "" and trim($footer) != "") {
            $removedlink = trim(str_replace($footerlink, "", $body));
            if (strstr($body, $removedlink)) {
                $body = $removedlink;
            }
            $body .= "\n\n[class=type-" . $type . "]" . $footer . "[/class]";
        }
        if ($no_tags) {
            return array("body" => $body, "tags" => "");
        }
        $tags_arr = array();
        foreach ($item->entities->hashtags as $hashtag) {
            $url = "#[url=" . $a->get_baseurl() . "/search?tag=" . rawurlencode($hashtag->text) . "]" . $hashtag->text . "[/url]";
            $tags_arr["#" . $hashtag->text] = $url;
            $body = str_replace("#" . $hashtag->text, $url, $body);
        }
        foreach ($item->entities->user_mentions as $mention) {
            $url = "@[url=https://twitter.com/" . rawurlencode($mention->screen_name) . "]" . $mention->screen_name . "[/url]";
            $tags_arr["@" . $mention->screen_name] = $url;
            $body = str_replace("@" . $mention->screen_name, $url, $body);
        }
        // it seems as if the entities aren't always covering all mentions. So the rest will be checked here
        $tags = get_tags($body);
        if (count($tags)) {
            foreach ($tags as $tag) {
                if (strstr(trim($tag), " ")) {
                    continue;
                }
                if (strpos($tag, '#') === 0) {
                    if (strpos($tag, '[url=')) {
                        continue;
                    }
                    // don't link tags that are already embedded in links
                    if (preg_match('/\\[(.*?)' . preg_quote($tag, '/') . '(.*?)\\]/', $body)) {
                        continue;
                    }
                    if (preg_match('/\\[(.*?)\\]\\((.*?)' . preg_quote($tag, '/') . '(.*?)\\)/', $body)) {
                        continue;
                    }
                    $basetag = str_replace('_', ' ', substr($tag, 1));
                    $url = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
                    $body = str_replace($tag, $url, $body);
                    $tags_arr["#" . $basetag] = $url;
                    continue;
                } elseif (strpos($tag, '@') === 0) {
                    if (strpos($tag, '[url=')) {
                        continue;
                    }
                    $basetag = substr($tag, 1);
//.........这里部分代码省略.........
开发者ID:git-marijus,项目名称:hubzilla-addons,代码行数:101,代码来源:twitter.php


示例13: statusnet_convertmsg

function statusnet_convertmsg($a, $body, $no_tags = false)
{
    require_once "include/oembed.php";
    require_once "include/items.php";
    require_once "include/network.php";
    $body = preg_replace("=\\[url\\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\\](.*?)\\[\\/url\\]=ism", "\$1.\$2.\$3.\$4/\$5", $body);
    $URLSearchString = "^\\[\\]";
    $links = preg_match_all("/[^!#@]\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $body, $matches, PREG_SET_ORDER);
    $footer = "";
    $footerurl = "";
    $footerlink = "";
    $type = "";
    if ($links) {
        foreach ($matches as $match) {
            $search = "[url=" . $match[1] . "]" . $match[2] . "[/url]";
            logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG);
            $expanded_url = original_url($match[1]);
            logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG);
            $oembed_data = oembed_fetch_url($expanded_url, true);
            logger("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG);
            if ($type == "") {
                $type = $oembed_data->type;
            }
            if ($oembed_data->type == "video") {
                //$body = str_replace($search, "[video]".$expanded_url."[/video]", $body);
                $type = $oembed_data->type;
                $footerurl = $expanded_url;
                $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
                $body = str_replace($search, $footerlink, $body);
            } elseif ($oembed_data->type == "photo" and isset($oembed_data->url) and !$dontincludemedia) {
                $body = str_replace($search, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body);
            } elseif ($oembed_data->type != "link") {
                $body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
            } else {
                $img_str = fetch_url($expanded_url, true, $redirects, 4);
                $tempfile = tempnam(get_temppath(), "cache");
                file_put_contents($tempfile, $img_str);
                $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                unlink($tempfile);
                if (substr($mime, 0, 6) == "image/") {
                    $type = "photo";
                    $body = str_replace($search, "[img]" . $expanded_url . "[/img]", $body);
                } else {
                    $type = $oembed_data->type;
                    $footerurl = $expanded_url;
                    $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
                    $body = str_replace($search, $footerlink, $body);
                }
            }
        }
        if ($footerurl != "") {
            $footer = add_page_info($footerurl);
        }
        if ($footerlink != "" and trim($footer) != "") {
            $removedlink = trim(str_replace($footerlink, "", $body));
            if ($removedlink == "" or strstr($body, $removedlink)) {
                $body = $removedlink;
            }
            $body .= $footer;
        }
    }
    if ($no_tags) {
        return array("body" => $body, "tags" => "");
    }
    $str_tags = '';
    $cnt = preg_match_all("/([!#@])\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $body, $matches, PREG_SET_ORDER);
    if ($cnt) {
        foreach ($matches as $mtch) {
            if (strlen($str_tags)) {
                $str_tags .= ',';
            }
            if ($mtch[1] == "#") {
                // Replacing the hash tags that are directed to the GNU Social server with internal links
                $snhash = "#[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]";
                $frdchash = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($mtch[3]) . ']' . $mtch[3] . '[/url]';
                $body = str_replace($snhash, $frdchash, $body);
                $str_tags .= $frdchash;
            } else {
                $str_tags .= "@[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]";
            }
            // To-Do:
            // There is a problem with links with to GNU Social groups, so these links are stored with "@" like friendica groups
            //$str_tags .= $mtch[1]."[url=".$mtch[2]."]".$mtch[3]."[/url]";
        }
    }
    return array("body" => $body, "tags" => $str_tags);
}
开发者ID:rabuzarus,项目名称:friendica-addons,代码行数:87,代码来源:statusnet.php


示例14: fbpost_fetchwall

function fbpost_fetchwall($a, $uid)
{
    require_once "include/oembed.php";
    require_once "include/network.php";
    require_once "include/items.php";
    require_once "mod/item.php";
    require_once "include/bbcode.php";
    $access_token = get_pconfig($uid, 'facebook', 'access_token');
    $post_to_page = get_pconfig($uid, 'facebook', 'post_to_page');
    $mirror_page = get_pconfig($uid, 'facebook', 'mirror_page');
    $lastcreated = get_pconfig($uid, 'facebook', 'last_created');
    if ((int) $post_to_page == 0) {
        $post_to_page = "me";
    }
    if ((int) $mirror_page != 0) {
        $post_to_page = $mirror_page;
    }
    $url = "https://graph.facebook.com/" . $post_to_page . "/feed?access_token=" . $access_token;
    $first_time = $lastcreated == "";
    if ($lastcreated != "") {
        $url .= "&since=" . urlencode($lastcreated);
    }
    $feed = fetch_url($url);
    $data = json_decode($feed);
    if (!is_array($data->data)) {
        return;
    }
    $items = array_reverse($data->data);
    foreach ($items as $item) {
        if ($item->created_time > $lastcreated) {
            $lastcreated = $item->created_time;
        }
        if ($first_time) {
            continue;
        }
        if ($item->application->id == get_config('facebook', 'appid')) {
            continue;
        }
        if (isset($item->privacy) && $item->privacy->value !== 'EVERYONE' && (int) $mirror_page == 0) {
            continue;
        } elseif (isset($item->privacy) && $item->privacy->value !== 'EVERYONE' && $item->privacy->value !== '') {
            continue;
        } elseif (!isset($item->privacy)) {
            continue;
        }
        if ($post_to_page != $item->from->id and (int) $post_to_page != 0) {
            continue;
        }
        if (!strstr($item->id, $item->from->id . "_") and isset($item->to) and (int) $post_to_page == 0) {
            continue;
        }
        $_SESSION["authenticated"] = true;
        $_SESSION["uid"] = $uid;
        unset($_REQUEST);
        $_REQUEST["type"] = "wall";
        $_REQUEST["api_source"] = true;
        $_REQUEST["profile_uid"] = $uid;
        //$_REQUEST["source"] = "Facebook";
        $_REQUEST["source"] = $item->application->name;
        $_REQUEST["extid"] = NETWORK_FACEBOOK;
        $_REQUEST["title"] = "";
        $_REQUEST["body"] = isset($item->message) ? escape_tags($item->message) : '';
        $pagedata = array();
        $content = "";
        $pagedata["type"] = "";
        if (isset($item->name) and isset($item->link)) {
            $item->link = original_url($item->link);
            $oembed_data = oembed_fetch_url($item->link);
            $pagedata["type"] = $oembed_data->type;
            $pagedata["url"] = $item->link;
            $pagedata["title"] = $item->name;
            $content = "[bookmark=" . $item->link . "]" . $item->name . "[/bookmark]";
            // If a link is not only attached but also added in the body, look if it can be removed in the body.
            $removedlink = trim(str_replace($item->link, "", $_REQUEST["body"]));
            if ($removedlink == "" or strstr($_REQUEST["body"], $removedlink)) {
                $_REQUEST["body"] = $removedlink;
            }
        } elseif (isset($item->name)) {
            $content .= "[b]" . $item->name . "[/b]";
        }
        $pagedata["text"] = "";
        if (isset($item->description) and $item->type != "photo") {
            $pagedata["text"] = $item->description;
        }
        if (isset($item->caption) and $item->type == "photo") {
            $pagedata["text"] = $item->caption;
        }
        // Only import the picture when the message is no video
        // oembed display a picture of the video as well
        //if ($item->type != "video") {
        //if (($item->type != "video") and ($item->type != "photo")) {
        if ($pagedata["type"] == "" or $pagedata["type"] == "link") {
            $pagedata["type"] = $item->type;
            if (isset($item->picture)) {
                $pagedata["images"][0]["src"] = $item->picture;
            }
            if ($pagedata["type"] == "photo" and isset($item->object_id)) {
                logger('fbpost_fetchwall: fetching fbid ' . $item->object_id, LOGGER_DEBUG);
                $url = "https://graph.facebook.com/" . $item->object_id . "?access_token=" . $access_token;
                $feed = fetch_url($url);
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:101,代码来源:fbpost.php


示例15: fbsync_createpost


//.........这里部分代码省略.........
            logger('fbsync_createpost: No matching contact found. Using own id. (Should never happen) ' . print_r($post, true), LOGGER_DEBUG);
            $contact_id = $self[0]["id"];
        }
        $postarray['contact-id'] = $contact_id;
    }
    $postarray["body"] = isset($post->message) ? escape_tags($post->message) : '';
    $msgdata = fbsync_convertmsg($a, $postarray["body"]);
    $postarray["body"] = $msgdata["body"];
    $postarray["tag"] = $msgdata["tags"];
    // Change the object type when an attachment is present
    if (isset($post->attachment->fb_object_type)) {
        logger('fb_object_type: ' . $post->attachment->fb_object_type . " " . print_r($post->attachment, true), LOGGER_DEBUG);
    }
    switch ($post->attachment->fb_object_type) {
        case 'photo':
            $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
            // photo is deprecated: http://activitystrea.ms/head/activity-schema.html#image
            break;
        case 'video':
            $postarray['object-type'] = ACTIVITY_OBJ_VIDEO;
            break;
        case '':
            //$postarray['object-type'] = ACTIVITY_OBJ_BOOKMARK;
            break;
        default:
            logger('Unknown object type ' . $post->attachment->fb_object_type, LOGGER_DEBUG);
            break;
    }
    $pagedata = array();
    $content = "";
    $pagedata["type"] = "";
    if (isset($post->attachment->name) and isset($post->attachment->href)) {
        $post->attachment->href = original_url($post->attachment->href);
        $oembed_data = oembed_fetch_url($post->attachment->href);
        $pagedata["type"] = $oembed_data->type;
        if ($pagedata["type"] == "rich") {
            $pagedata["type"] = "link";
        }
        $pagedata["url"] = $post->attachment->href;
        $pagedata["title"] = $post->attachment->name;
        $content = "[bookmark=" . $post->attachment->href . "]" . $post->attachment->name . "[/bookmark]";
        // If a link is not only attached but also added in the body, look if it can be removed in the body.
        $removedlink = trim(str_replace($post->attachment->href, "", $postarray["body"]));
        if ($removedlink == "" or strstr($postarray["body"], $removedlink)) {
            $postarray["body"] = $removedlink;
        }
    } elseif (isset($post->attachment->name) and $post->attachment->name != "") {
        $content = "[b]" . $post->attachment->name . "[/b]";
    }
    $pagedata["text"] = "";
    if (isset($post->attachment->description) and $post->attachment->fb_object_type != "photo") {
        $pagedata["text"] = $post->attachment->description;
    }
    if (isset($post->attachment->caption) and $post->attachment->fb_object_type == "photo") {
        $pagedata["text"] = $post->attachment->caption;
    }
    if ($pagedata["text"] . $post->attachment->href . $content . $postarray["body"] == "") {
        return;
    }
    if (isset($post->attachment->media) and ($pagedata["type"] == "" or $pagedata["type"] == "link")) {
        foreach ($post->attachment->media as $media) {
            if (isset($media->type)) {
                $pagedata["type"] = $media->type;
            }
            if (isset($media->src)) {
                $pagedata["images"][0]["src"] = $media->src;
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:67,代码来源:fbsync.php



注:本文中的oembed_fetch_url函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP of_get_default_values函数代码示例发布时间:2022-05-15
下一篇:
PHP oeFormatShortDate函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap