Reputation: 9885
I am trying to follow the information provided at This Page
This is the basic HTTP Request
I need to send,
https://foursquare.com/oauth2/authenticate
?client_id=YOUR_CLIENT_ID
&response_type=code
&redirect_uri=YOUR_REGISTERED_REDIRECT_URI
I have never used anything like this before and I am confused how to set this up.
I was reading that I need to initiate CURL
then send the request with CURL
So I am assuming something like this,
Based on an example I found,
$cur = curl_init("https://foursquare.com/oauth2/authenticate");
I am confused on how to add the other lines in and what is the basic principles behind each line from the given request provided by FourSquare?
To be clear how do I structure a statement like this with CURL
and how do I recognize what each line is provided by FourSquare?
Upvotes: 0
Views: 133
Reputation: 6275
So, the entire thing is the URL. Everything after the question mark "?" is called the query string. One way to do this in cURL is throw the whole thing in as a string.
$cur = curl_init("https://foursquare.com/oauth2/authenticate?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REGISTERED_REDIRECT_URI");
However you should NOT be using cURL to fetch this page, you should instead be directing the user to this page. The page you referenced is the page that lives on Foursquare where users can choose to connect to your app (or not). One way to do this is a redirection:
header("Location: https://foursquare.com/oauth2/authenticate?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REGISTERED_REDIRECT_URI");
exit(0);
YOUR_CLIENT_ID
and YOUR_REGISTERED_REDIRECT_URI
are things you can obtain and set from the Foursquare developer's site. Click on "My Apps" and check out your app (or create one if you have not done so). Be sure to replace them with the actual values.
The redirect uri is where foursquare will send a user after they "accept" your app. This should be a page or endpoint on your website. (i.e. https://mysite.com/accept_foursquare.php). Whatever this URL is, make sure that it is listed in your app on the Foursquare developer's site.
Upvotes: 1