Media_url not coming in json response

php

#1
<?php
ini_set('display_errors', 1);
require_once('TwitterAPIExchange.php');

/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
    'oauth_access_token' => "8xxxxxxxxxxYpA",
    'oauth_access_token_secret' => "MSxxxxxxxxxx29RlL",
    'consumer_key' => "mjxxxxxxx5F0t0",
    'consumer_secret' => "bnxxxxxoYRwG"
);

/** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
$url = 'https://api.twitter.com/1.1/blocks/create.json';
$requestMethod = 'POST';

/** POST fields required by the URL above. See relevant docs as above **/
$postfields = array(
    'screen_name' => 'SWANKY_co', 
    'skip_status' => '1',
	'tweet_mode' => 'extended',
	"include_entities" => "true"
);

/** Perform a POST request and echo the response **/
$twitter = new TwitterAPIExchange($settings);
 $twitter->buildOauth($url, $requestMethod)
             ->setPostfields($postfields)
             ->performRequest();

$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?screen_name=SWANKY_co&tweet_mode=extended';
$requestMethod = 'GET';

$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
    ->buildOauth($url, $requestMethod)
    ->performRequest();

$data = json_decode($response);

echo'<pre>';print_r($data);

#2

(never share your OAuth access tokens in public)

So far as I can tell, you’re blocking the user @SWANKY_co, then attempting to get back the timeline for that user? Not sure what the purpose of this code is here.

What Tweet ID is not showing the media properties?


#3

ok sure sorry for that
can you check my code


#4

here is Twitter id
831206203766108161


#5

That Tweet ID does not exist.


#6

Here is Json response can any help me why this happning . i have already use extends_mode but i am not getiing

Array
(
[0] => stdClass Object
(
[created_at] => Mon Apr 03 05:58:47 +0000 2017
[id] => 848776774691442688
[id_str] => 848776774691442688
[full_text] => ‘Why Power Brings Out Your True Self’ #YOURSELF https://t.co/dR3dbKL1UU
[truncated] =>
[display_text_range] => Array
(
[0] => 0
[1] => 71
)

        [entities] => stdClass Object
            (
                [hashtags] => Array
                    (
                        [0] => stdClass Object
                            (
                                [text] => YOURSELF
                                [indices] => Array
                                    (
                                        [0] => 38
                                        [1] => 47
                                    )

                            )

                    )

                [symbols] => Array
                    (
                    )

                [user_mentions] => Array
                    (
                    )

                [urls] => Array
                    (
                        [0] => stdClass Object
                            (
                                [url] => https://t.co/dR3dbKL1UU
                                [expanded_url] => http://m.nautil.us/issue/46/balance/why-power-brings-out-your-true-self
                                [display_url] => m.nautil.us/issue/46/balan…
                                [indices] => Array
                                    (
                                        [0] => 48
                                        [1] => 71
                                    )

                            )

                    )

            )

        [source] => Twitter for iPhone
        [in_reply_to_status_id] => 
        [in_reply_to_status_id_str] => 
        [in_reply_to_user_id] => 
        [in_reply_to_user_id_str] => 
        [in_reply_to_screen_name] => 
        [user] => stdClass Object
            (
                [id] => 831206203766108161
                [id_str] => 831206203766108161
                [name] => SWANKY_co
                [screen_name] => SWANKY_co
                [location] => Seattle, WA
                [description] => SWANKY_co represents : Success, Wealth, Ambition, Novelty, Knowledge, and Yourself. The co. represents the cooperative community behind the movement.
                [url] => 
                [entities] => stdClass Object
                    (
                        [description] => stdClass Object
                            (
                                [urls] => Array
                                    (
                                    )

                            )

                    )

                [protected] => 
                [followers_count] => 15
                [friends_count] => 25
                [listed_count] => 0
                [created_at] => Mon Feb 13 18:19:36 +0000 2017
                [favourites_count] => 1
                [utc_offset] => -25200
                [time_zone] => Pacific Time (US & Canada)
                [geo_enabled] => 
                [verified] => 
                [statuses_count] => 33
                [lang] => en
                [contributors_enabled] => 
                [is_translator] => 
                [is_translation_enabled] => 
                [profile_background_color] => F5F8FA
                [profile_background_image_url] => 
                [profile_background_image_url_https] => 
                [profile_background_tile] => 
                [profile_image_url] => http://pbs.twimg.com/profile_images/834152954387058688/C9DiRtPY_normal.jpg
                [profile_image_url_https] => https://pbs.twimg.com/profile_images/834152954387058688/C9DiRtPY_normal.jpg
                [profile_banner_url] => https://pbs.twimg.com/profile_banners/831206203766108161/1490685531
                [profile_link_color] => 1DA1F2
                [profile_sidebar_border_color] => C0DEED
                [profile_sidebar_fill_color] => DDEEF6
                [profile_text_color] => 333333
                [profile_use_background_image] => 1
                [has_extended_profile] => 1
                [default_profile] => 1
                [default_profile_image] => 
                [following] => 
                [follow_request_sent] => 
                [notifications] => 
                [translator_type] => none
            )

        [geo] => 
        [coordinates] => 
        [place] => 
        [contributors] => 
        [is_quote_status] => 
        [retweet_count] => 0
        [favorite_count] => 0
        [favorited] => 
        [retweeted] => 
        [possibly_sensitive] => 
        [lang] => en
    )

#7

here is the json response
Array
(
[0] => stdClass Object
(
[created_at] => Mon Apr 03 05:58:47 +0000 2017
[id] => 848776774691442688
[id_str] => 848776774691442688
[full_text] => ‘Why Power Brings Out Your True Self’ #YOURSELF https://t.co/dR3dbKL1UU
[truncated] =>
[display_text_range] => Array
(
[0] => 0
[1] => 71
)

        [entities] => stdClass Object
            (
                [hashtags] => Array
                    (
                        [0] => stdClass Object
                            (
                                [text] => YOURSELF
                                [indices] => Array
                                    (
                                        [0] => 38
                                        [1] => 47
                                    )

                            )

                    )

                [symbols] => Array
                    (
                    )

                [user_mentions] => Array
                    (
                    )

                [urls] => Array
                    (
                        [0] => stdClass Object
                            (
                                [url] => https://t.co/dR3dbKL1UU
                                [expanded_url] => http://m.nautil.us/issue/46/balance/why-power-brings-out-your-true-self
                                [display_url] => m.nautil.us/issue/46/balan…
                                [indices] => Array
                                    (
                                        [0] => 48
                                        [1] => 71
                                    )

                            )

                    )

            )

        [source] => Twitter for iPhone
        [in_reply_to_status_id] => 
        [in_reply_to_status_id_str] => 
        [in_reply_to_user_id] => 
        [in_reply_to_user_id_str] => 
        [in_reply_to_screen_name] => 
        [user] => stdClass Object
            (
                [id] => 831206203766108161
                [id_str] => 831206203766108161
                [name] => SWANKY_co
                [screen_name] => SWANKY_co
                [location] => Seattle, WA
                [description] => SWANKY_co represents : Success, Wealth, Ambition, Novelty, Knowledge, and Yourself. The co. represents the cooperative community behind the movement.
                [url] => 
                [entities] => stdClass Object
                    (
                        [description] => stdClass Object
                            (
                                [urls] => Array
                                    (
                                    )

                            )

                    )

                [protected] => 
                [followers_count] => 15
                [friends_count] => 25
                [listed_count] => 0
                [created_at] => Mon Feb 13 18:19:36 +0000 2017
                [favourites_count] => 1
                [utc_offset] => -25200
                [time_zone] => Pacific Time (US & Canada)
                [geo_enabled] => 
                [verified] => 
                [statuses_count] => 33
                [lang] => en
                [contributors_enabled] => 
                [is_translator] => 
                [is_translation_enabled] => 
                [profile_background_color] => F5F8FA
                [profile_background_image_url] => 
                [profile_background_image_url_https] => 
                [profile_background_tile] => 
                [profile_image_url] => http://pbs.twimg.com/profile_images/834152954387058688/C9DiRtPY_normal.jpg
                [profile_image_url_https] => https://pbs.twimg.com/profile_images/834152954387058688/C9DiRtPY_normal.jpg
                [profile_banner_url] => https://pbs.twimg.com/profile_banners/831206203766108161/1490685531
                [profile_link_color] => 1DA1F2
                [profile_sidebar_border_color] => C0DEED
                [profile_sidebar_fill_color] => DDEEF6
                [profile_text_color] => 333333
                [profile_use_background_image] => 1
                [has_extended_profile] => 1
                [default_profile] => 1
                [default_profile_image] => 
                [following] => 
                [follow_request_sent] => 
                [notifications] => 
                [translator_type] => none
            )

        [geo] => 
        [coordinates] => 
        [place] => 
        [contributors] => 
        [is_quote_status] => 
        [retweet_count] => 0
        [favorite_count] => 0
        [favorited] => 
        [retweeted] => 
        [possibly_sensitive] => 
        [lang] => en
    )

#8

There is no media attached to that Tweet (848776774691442688). There is a Twitter card, generated from the URL you are including.


#9

i have 33 Tweet in account and ecah one contain media
how to get that image


#10

I would recommend checking out a service like Embed.ly. They will crawl URLs for you and parse the metadata/images from them.


#11

That image is not part of the Tweet, it is part of the card, which is a hidden attachment to the Tweet. You’ll need to use another service as @abraham suggests.