Getting the user_id through Foursquare Api V2 - php

I'm working on a foursquare integration for a social good website, and I have everything working as I want it to, however I want to retrieve and store users foursquare user_id's so others can search for their friend. I've been searching all day, but I can't seem to find an end point, am I missing something? Or does this has to be done through user search? What is then best to use, as I have their email, and full name.
I am using jmathai's foursquare-async php libary. I think it should be easy but I just can't figure it out.

I've found the solution. To get an users' details you should use the end point "users/self". I had tried this before but got an error message. I think that was related to something else now.
After authenticating two lines are simply enough:
<?php
$fsObj->get("/users/self");
print_r($creds->response);
?php>
This gives an json array containing all relevant information on the user, including last checkins, name, and id. 'self' can here also be replaced by any user id you're authorized for on that moment.
For more information I'd recommend to visit Foursquare Api website

Related

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.

Is there a simple method using PHP for posting to Twitter without managing user logins or getting tweets?

I've seen there is some other discussion about this, however, none of the other threads I've read have targetted my situation.
For one, I do not need to get any Tweets from Twitter. I only need to send to Twitter.
For another, I don't need to have multiple accounts or different Twitter users. I can already ensure the page will only be seen by the one authorized user, so I can save any necessary login information in one configuration file and be done.
I am only posting occasionally from one web site, to one Twitter feed, and only one user will be logged onto the the web site that will send the tweet.
I am hoping to find a simple tutorial or script that can allow me to cut to the bare bones and just send tweets to my Twitter account.
However, all the tutorials and scripts I've seen so far have been too elaborate, handling logins, sessions, authenticating multiple users, and so on.
Is there any way I can get simple oAuth PHP code to accomplish what I'm describing?
This would help
http://code.google.com/p/dabr/source/browse/trunk/common/twitter.php
http://code.google.com/p/dabr/source/browse/trunk/common/OAuth.php
This should help or at least point you in the right direction.
https://dev.twitter.com/docs/twitter-libraries#php
You can use ZF component
get accessToken only once, keep it as serialized string anywhere
http://framework.zend.com/manual/en/zend.service.twitter.html

Problem using Linkedin API

I am using linkedin api to get info about the logged in user. I am able to get firstname and lastname, picture etc., It works fine. But I am not able to get recommendations. I am able to get number of recommenders using num-recommenders.
I am not getting **recommendations-received** according to http://developer.linkedin.com/docs/DOC-1061. I printed out the json response no recommendations Object for the user.
I appreciate your help.
For unfortunate reasons, if you want to get access to that field, you need to replace IN.API.Profile().fields("firstName","lastName","recommendationsReceived") with IN.API.Raw("/people/~:(first-name,last-name,recommendations-received)").
This is a good thread to read on the LinkedIn Developer forums: http://developer.linkedin.com/message/8805

Facebook Graph API : Some requests return an ampty data array

I hope someone wil be able to help to resolve my problem.
We can't say Facebook's forums are very useful for developers...
This is my problem.
On two different applications, I execute requests with Graph API.
For one of both, I make a friends request to invite user's friends to use application.
For the second application, I use Facebook Places to retrieve all informations about a location.
These two codes are simples functionnalities tests.
Before excute a request with Graph API, I ask to user to give me necessaries authorizations.
But results are, often, an empty JSON "data" array...
Before posting here, I search some solutions on internet.
Some people say application hasn't necessaries rights. Others user must like application page to retrieve informations correctly...
I tried these solutions... whithout concluant result.
For example, talking about my Facebook Place based application.
It asks user_checkins and friends_checkins rights.
Goal is to retrieve, for a given location, datas from users who're tagged there.
But I have an empty data array as return.
I tried my code in different ways, with PHP SDK, Javscript SDK and FQL. Same result.
Thanks :)
Sorry for my english. I'm a french developper ;)
For this - "Goal is to retrieve, for a given location, datas from users who're tagged there." Refer to https://developers.facebook.com/docs/reference/api/page/ and you will see that you can only get the checkin information for the current user or friend of the current user. In the case of a friend you will only get that information if the friend has allowed other apps to see this. So to test that you get data you should check in to a place (page), find the place's id, then make a query to https://graph.facebook.com/PAGE_ID/checkins with an access token that has user_checkins permission.
Also, here is a tool that you may find useful when debugging your API calls and permissions - https://developers.facebook.com/tools/explorer

Tracking user clicks back to Google Adwords API

I am going around in circles a bit with this one trying to find a solution online and I cant find one so I thought I would ask then it may be useful to others as well.
The scenario.
With PHP I am looking to talk back to the Google Adwords API. OK not a biggy. However I want to tie it in with our own back office system to marry up data from sales/conversions to impressions/clicks/costs of each campaign/adgroup in Google Adwords.
This would involve tagging the destination URLs I initially thought with the dynamic tag from Google of {creative} for example http://www.mydomain.com/productone/?adid={creative} however this appears to be a number which is not unique across the account but unique only under Adgroup. So AdgroupOne and AdgroupTwo could both have an adid of 1,2,3,4,5 etc.. Therefore you cannot use this id to pull the data.
Has anyone else encountered this? Is there a way of getting around it to get a unique indentifier which can be stored in the backoffice with each visit to trace back to Google Adwords via their API?
Really appreciate the help with this one as its got me stumped. Thanks guys.
The easiest way to fix this would be to provide your own ids in the url. Also maintain a map at your end, of the form (adgroupid, adId, your_tag_id). This way you can lookup the map to figure out what Ad was clicked when a url is hit.
Some id rules to keep in mind:
campaignId: Unique across system.
adGroupId: Unique across system.
adId: Unique within an adGroupId, so (adGroupId, adId) is unique across the system.
keywordId: Unique within an adGroupId, so (adGroupId, keywordId) is unique across the system.
Cheers,
Anash

Categories