On my site I've added a Tweet button. What I want to do is whenever user clicks on that button and the tweet gets posted on user's twitter account, I want to catch the unique id of that tweet and store it into the database.
Is it possible to do that using PHP??
When calling the REST API (http://api.twitter.com/1/statuses/update.json -- or whichever format), you get back the ID string. However, it also implies that you must route everything through your server using oAuth.
Alternatively, you could use the JavaScript API, along with one of the official Twitter JS widgets, and create an event listener to catch the tweet event. From there, you should have appropriate information in the data field of the event (something like evt.data), which you could pass to your server through AJAX.
JS Docs: https://dev.twitter.com/docs/intents/events
REST Docs: https://dev.twitter.com/docs/api
Related
I'm tryin to develop a (almost) 100% client-side dynamic website by integrating it with twitter, facebook and flickr.
I've been able so far to get the last 4 tweets (with javascript) from my client's feed, and now i was wandering if i could do the same with facebook's gallery and events from their feed.
Especially, what i need (given the facebook username/api key/whatever)
gallery
for each gallery in user's profile:
get the gallery name
get the first picture
get the gallery url
news/events
for each news/event/post in user's profile:
get the event name
get the event text
get the event picture (if provided)
get the event url
I don't want to use the facebook widgets with their rendering, i just need to read the json response (if there's any) and put the data inside my website (like a preview).
Since my client is pretty rusty with "computers (cit.)" but he's (not so strangely) comfortable with facebook/twitter/flickr, i tought about a solution like this before adding a database and an admin interface to our website.
I found some resources online, so i think it's possible (in a way or another). I'd like to do it in javascript, but if it's php i won't complain.
Check out this API to get photoes from the user profile
http://developers.facebook.com/docs/reference/api/album/
This is for events
http://developers.facebook.com/docs/reference/api/event/
You can use either the PHP or the Javascript API SDKs:
http://developers.facebook.com/docs/reference/php/
http://developers.facebook.com/docs/reference/javascript/
respectively. Naturally you would handle the returned information differently. Both have a method called api() which can be utilised to grab the album and event objects (as mentioned in another answer):
http://developers.facebook.com/docs/reference/api/album/
http://developers.facebook.com/docs/reference/api/event/
You can pass parameters in the methods to restrict the results returned by fields, number of items, sizes of images etc. This is outlined here:
http://developers.facebook.com/docs/reference/api/
But the issues you are going to face is that you have to authorise your "app" - think website when they use the terminology "app" - to give it permissions to access the information. This takes the form of a two step process. You have to create the app on the Facebook platform which can then access the API methods (only certain information can be got from the API methods without an authenticated app).
The second part is that the user themselves must then authenticate their facebook account against your app - this gives your app permission to access the user's information. In plain English it would go like this:
User visits your webpage; user must be logged into Facebook and must approve your app (this used to be called Facebook Connect for obvious reasons); the app and the user account are "connected"; the app can then use the api methods you've written to return information about the connected user
The beginning explanations of how to do this are here:
http://developers.facebook.com/docs/authentication/
The only way you can access a user's (non-public) information from outside of Facebook is via a connected app and user profile.
I would like to embed the facebook request form on the fan page without asking for permission, is it possible that the friend selector does not popup but instead displayed on the fan page?
The problem I am facing is
As I do not want to bother user for permissions I do not have the Current UserId, which I need for computation of who send how many request
Do not want the app request to popup
Do not want to use the fbml as it will get deprecated by June 2012
Any help how can I do this using PHP?
As you say yourself, you need the current user id. I'm sure you can get this without permissions along with other basic data such as name and gender etc.
try:
https://developers.facebook.com/tools/explorer/?method=GET&path=YOURUSERIDand you'll see.
As for showing the multi-friend selector in the page rather than as a popup, I've not done it myself but usually you can specify the display parameter, e.g. &display=page (rather than display=popup
Also, I think you have to use the JS SDK to do this and not PHP:
http://developers.facebook.com/docs/reference/dialogs/requests/
Also, if you want to send notifications to your user's friends then you will require permissions to do so.
So is there any working code in HTML/PHP that makes certain content () available only after the user clicks the "Like" button.
It's not an app, just an external website.
There is a callback when a Facebook button is 'liked' using Javascript
It's documented here
http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
The event is called edge.create by the looks of it.
There is no way to achieve your desired result - unless the user in question is also authenticated via facebook on your site, but I don't think that's the case.
The js like callback will (being a callback) only work after the user clicks like.
The thing you'd like to do is only possible within facebook pages' iframes, that are called with a signed request containing the current user's facebook id.
Is it possible to add some code that will tweet a message (or would offer to post a tweet) once a user submit a form yo post a message on my site.
Do I need to point it to my tweet account? Just trying the process.
I use PHP and jQuery on my site.
Yes it is possible. Yes, you do need to point it to some twitter account in your control (you could create a new one for your app/website).
See the twitter php libs.
I am building a news aggregator. How can I create button/ widget like Digg button or Facebook Share button that web developer can embed in their own website. When their users click on that button, it can trigger some function that interact (eg: voting or display vote amount) with my server. Thank you.
Simple solution: You need PHP script that accepts GET parameters. The third party can send data payload in the GET parameter and your script can read them and do the needful.
Voting third party via button shouldn't be done via GET params. This will create bad voting attacks. What you can do is make an API for your third party systems and have them do a CURL request to your API with the POST data payload. Again, this isn't the most secure. To make it more secure, use the API key and domain / IP check.
If your system is based on user sessions, you can do a cookie check to determine USER Information and read values. (similar to facebook LIKE).