# mentions on Facebook using Facebook Connect API - php

I am trying to do # mentions on Facebook using either facebook.stream.publish or facebook.users.setStatus.
You are able to do this on Facebook and I know its possible to do using 3rd party APIs as a "Twitter Sync" app currently supports it.
So far I have tried using: #[fb_id], #:fb_id, #[fb_id:fb_name], #:[fb_id:fb_name] and #:[fb_id] in the stream message.
I know Facebook.com uses #[fb_id:fb_name] on the site.
I also know Facebook's Dashboard API uses #:fb_id
I am also willing to emulate this functionality on my end if someone knows how to insert an url into the user's status or stream with custom link text or some method of inserting FBML into the stream (<fb:name>)
Note:
fb_id = Facebook User ID
fb_name = Facebook User Name
example: #[552192373:Jason Boehm]
I am currently using Facebook's Offical PHP API Client.

Related

Twitter API or Library to remember the session

I've been going through the Twitter API, but they are not as friendly as Facebook. My requirement is remember the authentication in the server / db and post user messages to the timeline without invoking twitter UI. Ofcourse I know we need to allow first time authentication via Twitter UI.
I'm not sure where to start and 2 days of Google search didn't end at any place where I can get started. Is there any document, resources, library (PHP or JavaScript) available to execute such scenario?
Thanks in advance.
This is a wonderful tutorial on how to auto post via PHP to Twitter. Check it out

Find YouTube username with YouTube / GooglePlus API

I'm fairly new to Stack Overflow, so if I am doing something wrong please tell me;
I have setup my website with the Google+ API - to log in, people click on a "Login With Google+" button and log in.
That's all fine and good, but I was wondering if I can integrate this login process with the YouTube API, so that when the user clicks the button to log in, I can also gather YouTube information.
I've already setup the YouTube Analytics and Data APIs on the Google API Console, I just need a code snippet to store the YouTube Username.
Expected Behavior:
User with URL 'youtube.com/some-user' logs in with Google+
Google+ Authentication Key is fed into some script
Script connects to YouTube API and returns username (eg $youtube_user = 'some-user')
My website takes this information and continues with the script
You can do this using the YouTube API. What you need to do is add an additional scope to your sign-in button. I would recommend you use the following scope:
https://www.googleapis.com/auth/youtube.readonly
Do this because you will not be managing anyone's YouTube account, just seeing their personal data (e.g. to pull in links or embed code for their YouTube videos).
Next, you need to perform an API call to YouTube using a client library. For experimentation, you can use the API explorer. To see your own information, authorize the request, set the part to "snippet" (no quotes) and then set mine to true.
Download the "youtube", "v3" static class from the PHP Google API client library, then make a call passing snippet as the part you want and "mine" set to true.
For listing the current user's videos, there is an example that ships with the PHP client library. The following change would list the user's activities:
// Exchange the OAuth 2.0 authorization code for user credentials.
$client->authenticate($code);
$token = json_decode($client->getAccessToken());
...
$activities = $youtube->activities->listActivities('snippet', array(
'mine' => 'true',
));
foreach ($activities['items'] as $activity) {
error_log(serialize($activity));
}
class's answer is spot on in terms of getting the OAuth 2 credentials to make the request. In terms of actual PHP code to work off of, you can use this example as a starting point (which uses this client library), and modify line 40 to read
$channelsResponse = $youtube->channels->listChannels('snippet', array(
'mine' => 'true',
));
And then you can access the channel's title via $channelsResponse['items'][0]['snippet']['title']. Note that it's possible to link a Google+ account and a YouTube channel, and if that's done, the channel's title will be equal to the Google+ account's display name. If this is an unlinked YouTube channel, then the legacy username of the channel will be returned instead.

google data api auth without raising user form login

I'm building an web which will get data from picasa. Several people will use. The web is just have 1 data source (1 picasa account) but I want to make the user authorized into that account without raising google form login page. I know that there is a solution using Zend_GData package, but from this site https://developers.google.com/picasa-web/code they say that API Versions Supported by the Client Library is v1. The google developer say that I should use Oauth 2.
Is it possible to make the several user use 1 data source (from 1 picasa account), without raising google form login? (the user can edit, delete, and add the source)
thx
if you are working with php then only version 1 is supported so use that only..
with oauth 2 you will not going to perform the operations which you can perform using Zend_GData..
and it is not possible to acess data with-out login.

Post directly to twitter and youtube

I am thinking of adding a feature to my website that allows me to write a post or add a video on my site and also post it to my twitter and/or youtube accounts with the click of a button. Does anyone know if there is a way to do this? I am not looking for code, just some links to documentation on how this is done.
Thanks.
Yes, there is. You have to connect with twitter and youtube, and you do it by using their API (Aplication Programming Interface). You register in their developers site and get a secret API key (kind of a password to allow you to use the API). Then, you just call their functions.
Twitter API: https://dev.twitter.com/
Youtube API: http://code.google.com/apis/youtube/overview.html
On these pages you will find code examples, libraries etc. which should be sufficient for you.

PHP class or library to allow tweeting from a website

I know there are quite a few libraries out there that that allow Twitter to be integrated into a website. But I haven't yet found what I am looking for (or maybe my understanding of twitter API is lacking). I want to be able to tweet events that occur on my website - BUT in addition, I want to be able to add tweeted from www.example.
For instance, when I send tweets from my blackberry or iphone (or indeed from some other sites), underneath the tweet, there is a message that says, tweeted from (for example blackberry). Does anyone know of a PHP library or class that allows me to send tweets but also with a kind of 'signature' that says where the tweet was sent from?
Edit
Additionally, I want users to be able to tweet from my website. When they tweet, I would like the tweet to say that where it came from (for example, like it does for blackberry phones etc, as I described above).
It is not clear to me whether I still need a PHP application for this requirement, and also how to implement it. Do I need an additional library for allowing users to tweet from my website?
Note: my users do not log into my website using a twitter login, so my website does not have access to a users Twitter username/password etc.
First you must register an app at http://twitter.com/apps, then you can use this twitter class -> http://classes.verkoyen.eu/twitter_oauth
I wrote a tutorial on how to do this http://blog.cmstutorials.org/reviews/general/how-to-update-your-twitter-status-using-php , just follow the steps and you should be good to go
edit: how to include a link
you can write function to get a shortened url because you only have 140 charachters
you can then use this function:
function getBitlyUrl($url)
{
$bitlylogin = 'your login name';
$bitlyapikey= 'your api key';
$bitlyurl = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$bitlylogin."&apiKey=".$bitlyapikey);
$bitlycontent = json_decode($bitlyurl,true);
$bitlyerror = $bitlycontent["errorCode"];
if ($bitlyerror == 0) {
$bitlyurl = $bitlycontent["results"][$url]["shortUrl"];
}
else $bitlyurl = "error";
return $bitlyurl;
}
then just call it like this:
$url = getBitlyUrl('yourlink');
you can then just add $url to your tweet
You need to create an application in twitter. And tweet via that application (using API) on twitter. the 'via XYZ' will be automatically added.
http://www.twitter.com/apps
You need to register an application at http://dev.twitter.com
(There you can also set information for "tweeted by" or your page url)
Afterwards you can use a library from the list here:
http://dev.twitter.com/pages/libraries#php
like https://github.com/abraham/twitteroauth or https://github.com/basilbthoppil/oauth_twitter
(It has to support the oauth authentication system I think some of the librarys on the twitter page are outdated)
When you create an instance of the library in your php script you have to pass your authentication tokens to the constructor (how you do this varies from library to library so just read the docs).
Any tweet posted by using the library will contain your "tweeted by" etc. information.

Categories