php - New Instagram API - php

I would like to implement Instagram for a Wordpress plugin.
This plugin will allow user to display instagram images with comments, likes, etc... I would like to use different source like user, tags, etc... There will be no interaction with like, comment system. It's just a plugin to display an instagram grid.
However I don't understand what is the right way to use the new API. On the instagram developer guide it's mentioned that the new API will be limited for the number of connections, etc... I don't know if it can concern my case for the plugin I want to develop.
To sum up, does the access token is enough to do what I want or do I need to use the API like this wrapper class with 'api Key', 'api Secret', 'api Callback'. It seems that information can be retrieve in different way but I don't understand what I should use. Or do I need to create an APP?
Maybe these questions can seem stupid but I'm not fluent in English and the developer guide of instagram is just not clear for me about the way I should use instagram for authentication/connection with any user.
I hope someone can guide me a little bit.

There is 2 ways you can approach this problem.
1) The plugin requires each user to register their own app with Instagram.
This means each user who installs the plugin would need to go through the app review process. Plus you would need to provide away for the users to supply their client_id, client_secret and a callback. Essentially you write the code to make everything work but the complexity of configuring the OAuth flow is still up to your users.
2) You register your plugin as an app with Instagram and make requests on your users behalf.
This is the intent of OAuth and Instagrams new API updates. This will also push all the complexity to you the plugin author. Since this is open code you will need to figure out away to keep your client_secret secure. One solution could be running a service for your plugin that handles the OAuth flow. You might also have API limit concerns depending upon your plugin adoption and usage.

Related

Add users post to their facebook newsfeed automtically with php

I have a website I'm working on. It enables users to register and post stuffs within the site. Can I get a link to some sort of api that allows people to add their facebook account (once) and then automatically post what they posted on my site on their facebook newsfeed (the sort of thing that happens when you connect your facebook account to your twitter account) .I've searched and can't seem to get exactly what I want
What you want is pretty common and if you searched you clearly didn't do a good job on the search.
Using the Facebook PHP SDK is pretty straight forward. There is a PHP Library available with a demo of the functionality you want. In your case you need to do some stuff more, so I'll explain globally what you should do:
Get the Facebook PHP SDK and load it into your website, determine what scope you need to perform the actions what you are going to do, in your case you need to have access to their timeline which is called the publish_stream scope. In order to get the Facebook PHP SDK working you need to create an app at http://developers.facebook.com
If a user grants access you need to save the authentication token that the user provides and save it in your database for later use. I'm not 100% sure how long they are valid, I think it's maximum of 30 days at the moment, but you have the ability to refresh the toking in the requests you make (correct me if I'm wrong, it's been a while..)
Everytime an action is done using the Facebook API you inject the usertoken in the request, thus performing the "post" action onto their timeline.
What you are looking for is pretty straight forward and easy to find..

How to know if someone is fan of my facebook page?

I know this subject has been done already over and over. but... i must be stupid so i'll try to figure out my problem simply.
I have a facebook page, let s say that one :
http://www.facebook.com/pages/Medieval-Forgecom/302734029745018
with a few fan poeple.
now on my website i would like to give a discount to poeple who are fan of that page.
So i tried the php api (with an application id and secret) before discovering that this is NOT what i want as my page is not an app and has no appId neither secret. Am i misunderstanding something here?
So i m wondering how in php i can know if someone is fan or not...
If it is not possible i could use the javascript api to make this check ( wich is quite bad, it should be done somewhere via php) but even this way i get trouble with the deprecated api and the code refering to javascript inside the facebook website.
in a nutshell, i'm lost.
thanks for your time and attention.
Do some research on the concept of "fan-gate". I think this is what you're looking for.
https://www.facebook.com/note.php?note_id=10150130919053430
http://www.youtube.com/watch?v=fBBnrtG0hAw
There are three ways of using Facebook API. Social plugins are widgets such as comments or like buttons. You can put them into your site directly and easily. And then there is the Graph API. First way of using this API is to create a whole standalone Facebook application, such as Farmwille. Second way is to use it only at your site, out of the Facebook frame. Regardless of the type of your usage, you need to register an application on Facebook, so Facebook API can authorize you. Without that you can't use the API. You don't need to create a real standalone app if you want only to use the API at your own site, but you must register it and this registration is just called Facebook application. It can be virtual application representing your site.

List all Google Apps Profiles on PHP Site

I am trying to get a list of all Google Apps users of a domain onto a public PHP website (without visitors of the site needing to login or do anything). I have a basic understanding of what needs to happen but can't quite piece it all together. It can't be as hard as it seems to me... could it?
Authentication and Authorization:
I'm pretty sure it needs to use OAuth 2.0 ... but am unsure whether it needs 2 legged or 3 legged. I got another section of the site working with ClientLogin but that won't pull in Google Apps profiles, only user's first and last names (I need the other profile fields). I have set up the API access within the account and have that side of things all set (I believe).
I have found this page, which shows how to construct a URL request to get all Profiles (in every language except PHP of course) but don't understand how to implement this.
http://code.google.com/googleapps/domain/profiles/developers_guide.html
I also tried this example but it just gives me a 401 after I enter the credentials. http://gdatatips.blogspot.com/2008/11/2-legged-oauth-in-php.html
I don't know which frameworks or includes are needed to accomplish this either. I have tried zend, OAuth.php and a whole bunch of other bootstraps... but keep getting lost as to what each is doing.
If someone could help me by outlining:
Which files/framework I need to upload and include as a bootstrap
What variables within those files I need to update with the Google credentials
How I integrate the Google Profiles "Retrieve all Profiles" request with PHP
An ELI5 (explain it like i'm 5) overview would be very much appreciated... I'm sorry for my apparent incompetence, but I have been reading articles for nearly a week and have not gotten anywhere.
Thank you in advance for any help provided.
Good question.
You'll need to implement the Google OAuth 2.0 process as it's described here (experimental?), because someone (you) will need to give your app the initial permissions to access Google Apps API. Steps are:
Register your domain with google (don't remember the link)
Redirect/send browser to an authentication url: https://accounts.google.com/o/oauth2/auth, with the appropriate request params (see the first link). You'll need access_type=offline, your scope would be https://apps-apis.google.com/a/feeds/user/
Get a code back, then exchange for a refresh_token, an access_token, and a value specifying when the access_token will expire. Store these in a database
Whenever you need to make an API call, check if your access_token has expired or not, and refresh when necessary, which is what the refresh_token is for. The refresh_token is valid as long as you don't revoke the access you gave to the app.
OAuth Playground helps a lot. Good luck.

Feasibility: Auto-tweet on Update of a page

On my company's website we have a display of 40 100px X 100px images that represent the projects that we have been involved in. We have more like 150 projects, but only 40 are displayed on the homepage and the selection of the 40 is random. See Example Here.
We also have an Update page which sorts these 40 projects by the date they were added. See Here.
In both cases the data is pulled from a PHP MySQL database and displayed as so on the website.
We are hoping to get a twitter presence as well as re-developing our website and I was wondering:
Is there a way to link twitter to the update page, so when I add a new project to the database, or update an existing project it automatically tweets about the new project?
Thanks in advance
It's definitely possible to do; however, since twitter turned off Basic Auth, you'll need to setup a twitter 'app' that you'll grant access to (oAuth) then use that to post. It adds a bit of complexity, but it shouldn't stop you.
Of course, if your CMS can provide an RSS feed of updates/additions (perhaps based on that update page), you could use one of the many RSS to Twitter posting services.
I'm a big fan of the way you can pick and chose Zend Framework's components, so I'd probably use Zend_Service_Twitter for something like this; however, the concept is similar on any Twitter library (or even just interfacing directly with Twitter, but that seems like unnecessary work).
First - as mentioned - you'll need tosetup an app on Twitter. The developer site should help there. You'll also need to **grant your new app access to the account you'll be posting to, what you need is an oAuth access token.
The access token is used for read/write, you'll use it to setup the Twitter library (again, an example from Zend's documentation, but it should be similar to other libraries):
$twitter = new Zend_Service_Twitter(array(
'username' => 'johndoe',
'accessToken' => $token
));
Then use whatever data the CMS provieds to create the 'update' post. Maybe something like this:
$status = "We just updated $projectName, check it out: $projectShortLink";
$response = $twitter->status->update($status);
Of course you'll need to make sure that's under the 140 limit.
It's pretty simple, the real overhead is setting up an 'app' and getting the oAuth token You'll need a simple one time script to request and retrieve the token (Zend's documentation gives examples) Or you could request permission for xAuth, but that seems a bit over the top for your application..
One potential benefit - since you're creating an app, you get to pick the 'via AppName' that's displayed in various clients.

Can you use the Facebook API to update a Page (rather than a Profile)?

As far as I can tell you can't add the Developer package to a Pages account - as in I haven't got a Facebook profile.
It's for business purposes and I'd really like to know if you can use the Facebook API to update a Pages status.
Thanks :)
Yes its possible although not officially documented.
Pageids behave in many function calls very similar to profileids.
You dont need to add the developer app to a page - remember: you neither need your users to add it.
I am pretty sure that the Stream API wont work. But you can do the approach described at http://www.allfacebook.com/2009/04/public-profile-twitter/
If you are not into Development and simply want to update your page you can use your twitter account and add a hashtag to sync it to your facebook page with Selective Twitter.
http://www.facebook.com/apps/application.php?id=115463795461
Update: as pointed out below http://ping.fm is also a good service offering this feature

Categories