Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Antes - helmikuu 14, 2014, 10:22:13 AP

Otsikko: Embed BBCode
Kirjoitti: Antes - helmikuu 14, 2014, 10:22:13 AP
I like twitter and it has some basic features can empower your community, one of them is embed, you can embed it via tweet by tweet or you can do it with entering tweet ID. I created a little bbcode for it but not sure why its not working :/

            array(
                'tag' => 'tweet',
                'type' => 'unparsed_content',
                'content' => '',$tweet2['html'] ,'',
                'validate' => create_function('&$tag, &$data, $disabled', '
                if (isset($disabled[\'url\']))
                    $tag[\'content\'] = \'$1\';
               
                global $tweet, $tweet2;
                $tweet = file_get_contents(\'https://api.twitter.com/1/statuses/oembed.json?id=$1\');
                $tweet2 = json_decode($tweet, true);
                $tag[\'content\'] = $tweet2[\'html\'];
                '),
                'block_level' => true,
                'disabled_content' => '$1'
            ),


Errors;

Undefined variable: tweet2
Undefined index: html
Otsikko: Re: Embed BBCode
Kirjoitti: Herman's Mixen - helmikuu 14, 2014, 10:49:07 AP
remove those damn slashes !!
Otsikko: Re: Embed BBCode
Kirjoitti: Antes - helmikuu 14, 2014, 11:04:50 AP
Lainaus käyttäjältä: Herman's Mixen - helmikuu 14, 2014, 10:49:07 AP
remove those damn slashes !!

Parse error: syntax error, unexpected 'url' (T_STRING) in **\Sources\Subs.php on line 991
Otsikko: Re: Embed BBCode
Kirjoitti: Antes - helmikuu 14, 2014, 03:56:08 IP
I still get "Undefined index: html" error and not outputting what it needs to :(
Otsikko: Re: Embed BBCode
Kirjoitti: Antes - helmikuu 14, 2014, 04:15:19 IP
It returns the values, i added a screenshot, upper part using this code;

   $tweet = file_get_contents("https://api.twitter.com/1/statuses/oembed.json?id=434084569902768129");
   $tweet2 = json_decode($tweet, true);
   echo $tweet2['html'];
Otsikko: Re: Embed BBCode
Kirjoitti: Antes - helmikuu 14, 2014, 04:48:58 IP
Thank you - emanuele & Little Craw ^^