Using Short Urls When Posting Tweets With CodeBird (PHP) - php

I'm currently using CodeBird to post tweets via PHP on my website. I've been using Bit.ly to post short URLS within those tweets. I would prefer to use the t.co short links that twitter creates but I am unsure how to do this.
\Codebird\Codebird::setConsumerKey("???", "???");
$cb = \Codebird\Codebird::getInstance();
$cb->setToken("???", "???");
$params = array('status' => $VideoTitle.' | Visit -> '.$VideoShortUrl, 'media[]' => 'hdefault.jpg');
$reply = $cb->statuses_updateWithMedia($params);
$array = json_decode(json_encode($reply), True);
Above is the code I use alongside the codebird.php file. Every tweet includes a title, url, and image. I'm looking to have the link I post (which is always 28+ characters) replaced with the twitter t.co short link.
I've read the twitter API documentation and other related questions on SOF but still have come up empty handed. I know twitter creates the link as soon as I post a tweet cause the array returns the short URL with all the other tweet details instantly.
The Twitter API says:
Links will be wrapped when Twitter receives a Tweet using POST statuses/update or a direct message using POST direct_messages/new.
I was thinking maybe codebird's wrapper wasn't unwrapping the links when it was returning the data, but I couldn't find anything there either. Does anyone know how I would go about replacing my URL with the t.co URL in the process of posting a tweet?
p.s
I've read that sometimes the short url creation 'could' be delayed, but none of my links are being changed. Also on a side note almost all the tweets are under 140 characters even with the long URL.

Every link posted to Twitter gets wrapped in the API. You don't need to do anything specific - just include a URl in your status.
When Twitter displays the tweets on its website, it will often show the original URL, but when you click on it, it goes via t.co
Can you show us an example of one of your Tweets which doesn't have a t.co link?

Related

Facebook OpenGraph: Use a facebook post URL as the canonical URL

I'm working on a service which can share url's to different social networks such as Facebook but I've run into some issues with how Facebook deals with it's own posts and content.
I've a page on my url, my-domain.com/share/u?URL where the URL parameter will be crawled and correct meta-tags and opengraph tags will be added to the page which then can be crawled by e.g. Facebook.
However, if I have a Facebook post URL (e.g. https://www.facebook.com/smashmag/posts/10154297276027490) and add this to my og:url meta-tag, facebook graph debugger reports it as a bug and when I try to share the custom url, it will not fetch or create a preview of it.
If I directly use the facebook share url with the post there are no issues (https://www.facebook.com/sharer/sharer.php?u=https://www.facebook.com/smashmag/posts/10154297276027490)
Is there any way to get around this or make facebook treat it's own URLs and posts as a valid og:url tag?
On my own service, I crawl facebook pages as well and here I can fetch the URL and create an embed post so this is not where the problem lies. It is simply when I want to share a custom URL on facebook, which actually is a redirect URL to a Facebook post URL.
Please let me know if I've explained myself unclear and I'll try to elaborate.

YouTube API PHP - Trouble retrieving full video description

I've been playing around with the google/google-api-php-client. I've noticed that it says "build-failing", but some parts are working as expected, so I've been pressing on with it.
So I have built a search field that queries the YouTube API for videos containing a search string and prints the results. You'll see that I've also hooked up the YouTube Player iFrame API to play the video if it is clicked.
Now these results do contain snippet data (title, description, channelId, etc...), but the item description's are limited to 160 characters and appended with an ellipsis ….
So now in an attempt to get a full description, I am sending another call to the YouTube API. I am calling $youtube->videos->listVideos('snippet',array('id' => '7dR02ebri9c')). The call is successful, but does not contain any snippet data.
I've logged the response to the console so you can see it here:
And printed it here incase the above image does not show.
{"etag":"\"43qFkeEQBKio26KDSq1ZQMzjhSo/3nlK0uyD_p1CFvvGkbiQcGORv5w\"","eventId":null,"kind":"youtube#videoListResponse","nextPageToken":null,"prevPageToken":null,"visitorId":null}
If I run the same request via the YouTube API Explorer, I receive a response complete with snippet data and a full description.
So I ask, is the problem the google/google-api-php-client I am using, the YouTube API itself, or perhaps something else?
Edit: I've found and thought about using madcoda/php-youtube-api instead, and will do-so if all else fails.
I've discovered that google/google-api-php-client was the problem here.
I've had success using madcoda/php-youtube-api instead.

Facebook search public photos by hashtag

I work with Facebook API SDK. I'm trying to get all public photos using https://graph.facebook.com/search?access_token=xxxx|xxxxx&q=%23hashtag&type=post
But I have a problem: result contains only shared photos in first account. When i'm posting photo without share, search not found it.
Otherwise, I have another account where I'm posted photo and share it, but photo is not found too.
Who knows, how can I get all public photos with hastag using FQL or graph search
Addition:
Few days ago - facebook search is not working
After discussing with facebook developers, I got the answer:
Facebook API does not support searching for hashtags.
%23 is just the URL encoded version of a # which gets decoded on a
server generally so it still won't work. For example if I wanted to
search for #YOLO I would just say q=YOLO with no # or it's URL encoded
form.
It's just something that the api doesn't support at the moment
Facebook has officially deprecated the post search type. Im not sure when exactly but I can tell you I tried today (10/15/2014) and its a no go.

Publish flash player in user wall does not work?

Hi first i want to clarify that this is not a question about how to embed a flash player in user wall, because i already know how to do it.
The question is if anybody can help me whith my code or if someone has the same problem as me and it is a bug.
I want to publish this link ( http://www.test.hollybyte.tv/watch/4e45080a94a05f1478000000 ) into wall via Graph Api. If you see the code of the link you can see that the required metas are wrote. In fact, if you paste the link in Fb, you can see that it recognise and even publish the player.
For test purpose i have used the Graph API Explorer ( http://developers.facebook.com/tools/explorer ) with this parameters:
Method: "POST"
Api : https://graph.facebook.com/user/feed
oauth_token : ...
message: "Test from API Explorer"
link: http://www.test.hollybyte.tv/watch/4e45080a94a05f1478000000
picture: http://repo.eu-w1.hollybyte.com/acc/test/as/4e45080a94a05f1478000000/splash.jpg
source: http://repo.eu-w1.hollybyte.com/acc/test/py/default-flash/swf/flowplayer.commercial-3.2.7.swf?config=http://repo.eu-w1.hollybyte.com/acc/test/st/www/default/js/emb/4e45080a94a05f1478000000.js
type: video
And it does post perfectly well, wiht the player !!
But when i tried the same thing wiht PHP using Facebook PHP SDK, it does not. It publish a link but with no picture, nor player either.
My PHP code for this is:
$facebook = new Facebook( array('appId' => $this->_appId, 'secret' => $this->_appSecret));
$param = array(...); //Array with all the data from above, the same data.
$result = $facebook->api('/'.$userId.'/feed', 'post', $param);
echo $result;
I do not understand why, whith the API Explorer works fine, but whit my PHP call does not. Please tell me if it is a bug, or what i am doing wrong.
I have to say that i have all permissions right (publish stream, offline access, read stream), and i can post to wall so it is not a permission problem (or correcti if i am wrong)
Thanks in advance for your answers.
P.D.
I am not used to write in english, so forgive me if i have some grammar errors.
From the Feed dialog documentation, It doesnt look like there is supposed to be a type parameter in the param array... In addition, the message parameter should not be used - facebook said that they will start ignoring that parameter from July 12 :
"This field will be ignored on July 12, 2011"
They also say things like
The URL of a media file (e.g., a SWF or video file) attached to this post. If both source and picture are specified, only source is used.
You should try removing unnecessary parameters. I dont believe that there is a bug with the API... Most of the times when I have encountered these types of bugs it was an issue of wrong parameters.
Just to clarify the solution.
If you want to publish a link to a flash player in user wall. You only need tree paremeters
Message: The message you want (optional).
Link: A link to the page with the player. The page must have the proper metas (video_src, video_img, etc...)
Type: Video.
And only those parameters, no more.
Thanks Lix to show me the way.
Tolke does your embed still work ? It seems that Flash ,Video Embed is not working anymore mostly all over FB. Two exceptions youtube and vimeo serving over https .
dont get it to work with the usual parameter

twitter application in tweet box

I want to know about the twitter status update from any one of the particular website. Currently as I am working with twitter status update, It's working fine. My question is: If I tweet anything in this tweet box it goes to this (http://t.co/fhlgeXf) URL. If I visited to on my twitter account it has been updated by that url: http://t.co/fhlgeXf.
But, I want that, the tweets go to my website URL with given my application name.. I have created API console which I created for via...
So finally I need the every updates go with my url link and my application via.
How can i get this?
If you are using the twitter's tweet box, all url's will be shortened with twitter's t.co url shortener. It will not allow you to include your original url there. This is actually a safety measure so that they can stop any rogue spam apps from spreading.
To tweet your links and have the 'via application', you will have to use twitter's OAuth implementation. There is a client side javascript API that you can use. Also there is a server side implementation that you may want to look into.

Categories