TijsVerkoyen\Twitter\Twitter::statusesOEmbed PHP Method

statusesOEmbed() public method

public statusesOEmbed ( string[optional] $id = null, string[optional] $url = null, int[optional] $maxwidth = null, bool[optional] $hideMedia = null, bool[optional] $hideThread = null, bool[optional] $omitScript = null, string[optional] $align = null, string[optional] $related = null, string[optional] $lang = null ) : array
$id string[optional]
$url string[optional]
$maxwidth int[optional]
$hideMedia bool[optional]
$hideThread bool[optional]
$omitScript bool[optional]
$align string[optional]
$related string[optional]
$lang string[optional]
return array
    public function statusesOEmbed($id = null, $url = null, $maxwidth = null, $hideMedia = null, $hideThread = null, $omitScript = null, $align = null, $related = null, $lang = null)
    {
        if ($id == null && $url == null) {
            throw new Exception('Either id or url should be specified.');
        }
        // build parameters
        $parameters = null;
        if ($id != null) {
            $parameters['id'] = (string) $id;
        }
        if ($url != null) {
            $parameters['url'] = (string) $url;
        }
        if ($maxwidth != null) {
            $parameters['maxwidth'] = (int) $maxwidth;
        }
        if ($hideMedia !== null) {
            $parameters['hide_media'] = $hideMedia ? 'true' : 'false';
        }
        if ($hideThread !== null) {
            $parameters['hide_thread'] = $hideThread ? 'true' : 'false';
        }
        if ($omitScript !== null) {
            $parameters['omit_script'] = $omitScript ? 'true' : 'false';
        }
        if ($align != null) {
            $parameters['align'] = (string) $align;
        }
        if ($related != null) {
            $parameters['related'] = (string) $related;
        }
        if ($lang != null) {
            $parameters['lang'] = (string) $lang;
        }
        // make the call
        return $this->doCall('statuses/oembed.json', $parameters);
    }

Usage Example

Beispiel #1
0
 /**
  * Tests Twitter->statusesOEmbed()
  */
 public function testStatusesOEmbed()
 {
     $response = $this->twitter->statusesOEmbed('240192632003911681');
     $this->assertArrayHasKey('provider_name', $response);
     $this->assertArrayHasKey('provider_url', $response);
     $this->assertArrayHasKey('author_name', $response);
     $this->assertArrayHasKey('author_url', $response);
     $this->assertArrayHasKey('url', $response);
     $this->assertArrayHasKey('cache_age', $response);
     $this->assertArrayHasKey('type', $response);
     $this->assertArrayHasKey('version', $response);
     $this->assertArrayHasKey('height', $response);
     $this->assertArrayHasKey('width', $response);
     $this->assertArrayHasKey('html', $response);
 }
Twitter