Tweets with "Media" inside - twitter

I see some tweets have some kind of HTML embedded. How is it possible to do this?

It certainly is a list of hardcoded partnerships, as #dtt101 suggested.
Evidence: here's a list of partners as taken from their javascript source (the js file with "hogan-more" in it, e.g. at t1-hogan-more-en-201203071014.js ):
edit: updated with domain names from the source
Amazon: www.amazon.com
AolVideo: http://www.aol.com
Apple: http://itunes.apple.com
BlipTV: blip.tv
CNN: http://cnn.com
DailyBooth: dailybooth.com
DeviantArt: http://deviantart.com
Dipdive: http://dipdive.com
Etsy: http://etsy.com
Facebook: https://facebook.com or http://facebook.com
Flickr: https://secure.flickr.com or http://www.flickr.com
Foursquare: www.foursquare.com
GoogleVideo: http://video.google.com
Gowalla: www.gowalla.com
Hulu: http://www.hulu.com
Instagram: instagr.am
JustinTV: http://justin.tv
Kickstarter: kickstarter.com
Kiva: http://www.kiva.org
Livestream: http://www.livestream.com
Lockerz: www.lockerz.com
Meetup: www.meetup.com
MSNBC: http://msnbc.com
MTV: http://mtv.com
NHL: http://www.nhl.com
Photobucket: http://photobucket.com
Photozou: http://photozou.jp
Plancast: plancast.com
Rdio: rdio.com
SlideShare: http://slideshare.com
Twitgoo: http://twitgoo.com
TwitPic: twitpic.com
Twitter: twitter.com
CopiedTwimg: twitter.com
Twimg: twitter.com
TwitVid: www.twitvid.com
Ustream: http://ustream.tv
Vevo: http://vevo.com
Vimeo: vimeo.com
WallStreetJournal: http://online.wsj.com
WashingtonPost: http://washingtonpost.com
WhoSay: www.whosay.com
With: https://with.me or http://with.me
WordPress: wordpress.com
YFrog: yfrog.com
Youtube: www.youtube.com

https://dev.twitter.com/blog/photo-upload-api tells you how it works. There is an API which you can use to attach photos to tweets.

It's based on the oembed standard, but I don't know how you get on the list of approved oembed providers.

Related

Twitter API 1.1 - render twitter's t.co links

I want to display the tweets of an account in my website. The problem is that the tweets appear always with the format http://t.co/..., instead of the full link as desired by me.
For instance, I obtain:
the rules of the game are all implemented - local players can play together in this link: http://t.co/Nf7j4TaB
if you are very curious... then, here is the link to the xodul's section under development: http://t.co/6Zbti36T
etc...
and I want that these tweets appear like this:
the rules of the game are all implemented - local players can play together in this link: http://xodul.com/tests/js/
if you are very curious... then, here is the link to the xodul's section under development: http://xodul.com/tests
etc...
To make my application I've followed the instructions from:
Simplest PHP example for retrieving user_timeline with Twitter API version 1.1 (from here we can get the text of each tweet, with the links coming in the format: http://t.co/...)
Rendering links in tweet when using Get Statuses API 1.1 (the code of the highest scored answer, in this link replaces, for instance, the text "http://t.co/Nf7j4TaB" with the hyperlink "<a target='_blank' href='http://t.co/Nf7j4TaB'>http://t.co/Nf7j4TaB</a>")
I appreciate very much any help on how to render the twitter's links!
With the tutorial you followed you can use these attributes to show actual link.
Note: In API v1.1, entities will always be included unless you set include_entities to False or 0.
The urls entity
An array of URLs extracted from the Tweet text. Each URL entity comes with the following attributes:
url: The URL that was extracted
display_url: (only for t.co links) Not a URL but a string to display instead of the URL
expanded_url: (only for t.co links) The fully resolved URL
indices: The character positions the URL was extracted from
https://dev.twitter.com/docs/tweet-entities
JavaScript only solution for now to get Twitter posts on your site without using new 1.1 API and actually returns the full url in posts, not the twitter shortened version :-) http://goo.gl/JinwJ
Thank you for your answers.
After analyzing the JSON in the suggested link (https://dev.twitter.com/docs/tweet-entities), I wrote a solution to the exposed problem:
// ...
$twitter_data = json_decode($json); // last line of the code in: http://stackoverflow.com/questions/12916539
// print the tweets, with the full URLs:
foreach ($twitter_data as $item) {
$text = $item->text;
foreach ($item->entities->urls as $url) {
$text = str_replace($url->url, $url->expanded_url, $text);
}
echo $text . '<br /><br />';
// optionally, here, the code from: http://stackoverflow.com/questions/15610968/
// can be added, too.
}

Can't get views by insightTrafficSourceType — YouTube Analytics API

So I'm using the 'google-api-client' gem with Rails, and I'm attempting to call the URL below in order to get video views by day and insightTrafficSourceType. This is a call that appears to be allowable from the Available Reports documentation page.
Additionally, I found that I was able to make this call by using the API Explorer tool provided by Google.
URL:
https://www.googleapis.com/youtube/analytics/v1beta1/reports?metrics=views&ids=channel==CHANNEL_ID&dimensions=day,insightTrafficSourceType&filter=video==VIDEO_ID&start-date=2013-01-15&end-date=2013-01-16&start-time=1970-01-01
Result:
{
:error=>
{
"errors"=>[
{
"domain"=>"global",
"reason"=>"invalid",
"message"=>"Unknown identifier (insightTrafficSourceType) given in field parameters.dimensions."
}
],
"code"=>400,
"message"=>"Unknown identifier (insightTrafficSourceType) given in field parameters.dimensions."
}
}
I'm not sure what extra data I can provide in the initial description of this bug, but as stated before I am making the call to the API with the Google::APIClient Ruby library. The actual code itself looks like this:
client.execute(
:api_method => api.reports.query,
:parameters => options
)
You are still referencing the old beta API, i.e., in your URL, you have 'v1beta' and you should have 'v1' there. Try replacing that and running it again. Also, you can look at the api explorer to see the exact URL that should be generated in live examples with your acct (once you enable OAuth) here:
https://developers.google.com/youtube/analytics/v1/
(Look at the bottom of the page.)
Finally, start-time isn't a parameter listed on the production version of the API, so you will want to remove that as well.

How can I get a channel ID from YouTube?

I'm trying to retrive the data from my channel using the YouTube Data API V3.
For that I need my channel ID.
I've tried to find my channel ID from my YouTube account, and I failed in every single way.
If anyone have a single tip for me, I would be incredible glad.
This is the URL that I'm using to retrieve the data:
https://www.googleapis.com/youtube/v3/channels?id=fjTOrCPnAblTngWAzpnlMA&key={YOUR_API_KEY}&part=snippet,contentDetails,statistics
The ID is for the channel ID, and the key, I'm replacing the {YOUR_API_KEY} with my API KEY generated at my Google API console.
My channel ID is not:
- klauskkpm
- klausmachado
- klausmachado#gmail.com
- fjTOrCPnAblTngWAzpnlMA
My channel is: http://www.youtube.com/user/klauskkpm
To obtain the channel id you can view the source code of the channel page and find either data-channel-external-id="UCjXfkj5iapKHJrhYfAF9ZGg" or "externalId":"UCjXfkj5iapKHJrhYfAF9ZGg".
UCjXfkj5iapKHJrhYfAF9ZGg will be the channel ID you are looking for.
An easy answer is, your YouTube Channel ID is UC + {YOUR_ACCOUNT_ID}.
To be sure of your YouTube Channel ID or your YouTube account ID, access the advanced settings at your settings page
And if you want to know the YouTube Channel ID for any channel, you could use the solution #mjlescano gave.
https://www.googleapis.com/youtube/v3/channels?key={YOUR_API_KEY}&forUsername={USER_NAME}&part=id
If this could be of any help, some user marked it was solved in another topic right here.
You can get the channel ID with the username (in your case "klauskkpm") using the filter "forUsername", like this:
https://www.googleapis.com/youtube/v3/channels?key={YOUR_API_KEY}&forUsername=klauskkpm&part=id
More info here: https://developers.google.com/youtube/v3/docs/channels/list
At any channel page with "user" url for example http://www.youtube.com/user/klauskkpm, without API call, from YouTube UI, click a video of the channel (in its "VIDEOS" tab) and click the channel name on the video. Then you can get to the page with its "channel" url for example https://www.youtube.com/channel/UCfjTOrCPnAblTngWAzpnlMA.
I just found the simplest way to find the channel ID of any YouTube channel !!
Step 1: Play a video of that channel.
Step 2: Click the channel name under that video.
Step 3: Look at the browser address bar.
June 2021 edition.
Right click and view page source.
Search for "externalId", the value follows.
Source: comment by Daniel 2017.
Alternative: run this JavaScript in console:
ytInitialData.metadata.channelMetadataRenderer.externalId
An alternative to get youtube channel ID by channel url without API:
function get_youtube_channel_ID($url){
$html = file_get_contents($url);
preg_match("'<meta itemprop=\"channelId\" content=\"(.*?)\"'si", $html, $match);
if($match && $match[1])
return $match[1];
}
As of 2022-06-23:
Open Chrome Dev Tools (F12), and in the "Elements" tab, within the source code pane, depending on URL type:
A. For channel URLs of type: www.youtube.com/c/<channel_name>:
Search for either:
"externalId" - next to it there will be the channel_ID
"channelUrl" - next to it there will be: https://www.youtube.com/channel/<channel_ID>
or run in the console:
ytInitialData.metadata.channelMetadataRenderer.externalId
(credit: https://stackoverflow.com/a/68063136/624597)
B. For video URLs of type: www.youtube.com/watch?v=<video_ID>:
Search for either:
"externalId" - next to it there will be the channel_ID
"externalChannelId" - next to it there will be the channel_ID
"ownerProfileUrl" - next to it there will be: https://www.youtube.com/channel/<channel_ID>
or run in the console:
ytInitialPlayerResponse.microformat.playerMicroformatRenderer.externalChannelId
Channel id with the current youtube version is obtained very easily if you login to YouYube website and select 'My channel'
Your channel ID will be displayed on the address bar of your browser
https://www.youtube.com/account_advanced now provides both channel and user ids. See also https://developers.google.com/youtube/v3/guides/working_with_channel_ids .
2017 Update: Henry's answer may be a little off the mark here. If you look for data-channel-external-id in the source code you may find more than one ID, and only the first occurrence is actually correct. Get the channel_id used in <link rel="alternate" type="application/rss+xml" title="RSS" href="https://www.youtube.com/feeds/videos.xml?channel_id=<VALUE_HERE"> instead.
To obtain the channel id you can do the following request which gives you the channel id and playlist id.
https://www.googleapis.com/youtube/v3/channels?part=contentDetails%2C+statistics%2Csnippet&mine=true&key={YOUR_API_KEY}
mine parameter means the current authorized user
as u said channel id is prefixed with UC+{your account id} which you get while login, you can use this one also without requesting the above url you can directly call the channel api with your google id and just prefix with UC
https://www.googleapis.com/youtube/v3/channels?part=contentDetails%2C+statistics%2Csnippet&id=UC{your account id}&key={YOUR_API_KEY}
Apparently there is a channelId attribute in video page's source code;
To get Channel id
Ex: Apple channel ID
Select any of the video in that channel
Select iPhone - Share photos (video)
Now click on channel name Apple bottom of the video.
Now you will get channel id in browser url
Here this is Apple channel id : UCE_M8A5yxnLfW0KghEeajjw
Try to search for regular expression UC[-_0-9A-Za-z]{21}[AQgw] in source code. This ID is presented even if channel has non-ASCII characters in URL:
Here is screenshot of internal viewer/editor of Midnight Commander, it has regexp search:
Alternatives to get the channel URL with its ID.
With a CSS selector by searching the channel homepage source code:
body > link[rel="canonical"]
or with JS via the console:
document.querySelector('body > link[rel="canonical"]').href
Another method to find the ID of a channel that is not yours is to go to the channel page and press the red "Subscribe" button.
Then use the Chrome's Inspector tools Network tab and look for the POST request issued by the subscribe action. In the payload of this request you will find the channel id:
You can unsubscribe immediately after subscribing.
Now in 2023, typing this in console should work:
document.querySelectorAll('[itemprop="channelId"]')[0].content

How do I fetch orgusers beyond the 1st 100 using the Google Apps OrgUser provisioning API feed

I am using Zend's gdata library for the Google Apps provisioning API. Since Zend doesn't yet support fetching org users (no retrieve function provided by the library for this feed), I am making a custom gdata query to the url (as suggested in the documentation developers.google.com/google-apps/provisioning/#retrieving_organization_users_experimental):
apps-apis.google.com/a/feeds/orguser/2.0/'.$customerId.'?get=all
This works well for <= 100 users.
Now, I have created a domain with 125 users across 5 OUs. When I fetch the above URI, I get the 1st 100 users (as documented and expected). However, I could not find the pagination link mentioned here: developers.google.com/google-apps/provisioning/reference#Results_Pagination
Here's the start of my orguser feed:
<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:apps='http://schemas.google.com/apps/2006'><id>https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx</id><updated>2013-01-06T08:17:43.520Z</updated><**link rel='next' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all&startKey=RASS03jtnz0s2orxmbn.**'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxx'/>
I tried the https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all&startKey=RASS03jtnz0s2orxmbn. link but it gives me the exact same 100 users that the https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all link gives. This is the only occurrence of the word "next" in my feed and so there is not other URI I can try to fetch the next 25 users.
So I have only been able to get 100 users from this API call. How do I go about fetching the next 25 users? Examples/code would be really appreciated. Or what am I doing wrong?
Please help - this is blocking an urgent delivery.
Thanks!,
Vinay.
Your 2nd request should look like:
https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxx?startKey=RASS03jtnz0s2orxmbn&get=all
startKey should be set to the value of the next parameter and get should continue to be all for each page request.
Also, make sure the URL is decoded, if & is encoded as & in the request, then Google's servers will see all of all&startKey=RASS03jtnz0s2orxmbn as the value of get and it won't see a startKey parameter at all.

Finding Facebook ID from URL

In Facebook's documentation it says you can find the ID from a URL, and that used to be the case. It doesn't appear to be true anymore.
This example is straight from Facebook's API Documentation:
--------------FACEBOOK DOCS---------------------
The "ids" query parameter also accepts URLs. This is useful for finding IDs of URLs in the Open Graph. For example: https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
But when you click on that link it gives you:
{
"http://www.imdb.com/title/tt0117500/": {
"id": "http://www.imdb.com/title/tt0117500/",
"shares": 18226,
"comments": 7
}
}
Which does NOT include the real Facebook ID for this example URL. If I go to the debugger and enter this URL I can find the ID, which is: 380728101301
So how can I find the ID without using the Open Graph Debugger? I need to be able to get IDs through the code on my site, and can't manually visit the debugger every time.. anyone know how to do this now?
Thanks very much!
There is one possibility with FQL:
SELECT url,site,id FROM object_url WHERE url = 'http://www.imdb.com/title/tt0117500';
https://developers.facebook.com/docs/reference/fql/

Resources