Checking if a facebook profile is verified or not? - ruby-on-rails

I am developing an app in which I want to know if a facebook authorized user has a verified profile or not. I can see that there is a is_verified field that facebook provides. I am just not getting it in the response I get from OAuth. Is there any permissions issue? I am using permissions public_profile,email. Please guide me on this.

You can ask 'is_verified' field in your query. You can try below code as a sample and u can take the appropriate part of the code to integrate in yours. public_profile,email permission is enough to get this field. result will be a bolean
$fb_page = 'barackobama'; //any fb page,fb profile
$access_token = ''; //your access token
$url = "https://graph.facebook.com/v2.2/".$fb_page.'
?access_token='.$access_token.'&fields=is_verified';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
curl_close($curl);
$details = json_decode($result,true);
echo "verified:".$details['is_verified'];

Related

how to pass oauth2 token to mashup filab?

I have followed the whole process to obtain an oauth2 access token from the Identity Manager (I get it) and I want to pass it to a web application developed on Filab Mashup but embedded in my own web.
In my Mashup application I need get the oauth token for to access Orion Context Broker information but I don't know how to pass it.
This is the code of my callback URL where I obtain the token:
<?php
//get the code from url
$code = $_GET["code"];
//print_r($code);
//application specific declarations
$domain = "www.talkysync.com";
$clientId = "my_client_ID";
$clientSecret = "my_client_secret";
//access token url
$url = 'https://account.lab.fiware.org/oauth2/token';
//payload params for the request token
$payload = 'grant_type=authorization_code&code='. $code .'&redirect_uri=http%3A%2F%2Fwww.talkysync.com%2Ffiware_login%2Fcallback.php';
//base64(client_id:client_secret)
$cadena = $clientId . ":" .$clientSecret;
$base = base64_encode($cadena);
//extra header for the request
$header = array("Content-Type: application/x-www-form-urlencoded", "Authorization: Basic ". $base);
//actual request implementation
$ch = curl_init($url);
curl_close($ch);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
;
//get the access token from the json response
$jsonData = json_decode($output,true);
$access_token = $jsonData["access_token"];
//start a session and set the access token to it
session_start();
$_SESSION["X-Auth-Token"] = $access_token;
$_SESSION["code"] = $code;
header("Location: fiware.php");
?>
And this is the code of fiware.php:
<?php
session_start();
if(!isset($_SESSION["X-Auth-Token"])){
header('Location: login.php');
}else{
header('Location: https://mashup.lab.fiware.org/ertonio/Talkykar?mode=embedded');
}
?>
But in the mashup application I always have an anonymous connection because I don't know how to pass it the token.
Thanks in advance.
Currently is not possible to create an embedded WireCloud URL including the credentials. Seems interesting and worth implementing it, but also seems a lot of work, so don't expect it to be implemented in a short period of time.
Regarding, accessing the orion context broker from WireCloud, take a look into section "3.2.1. Using Orion Context Broker" on the WireCloud's course available on the FIWARE Academy.

EventBrite API - How Do I Get Only Live Events for my User?

I'm using PHP and CURL to try and get all my account's events from EventBrite's web service.
I'm running this script (edited down slightly):
$curl = curl_init();
$hdr = array();
$hdr[] = 'Authorization: Bearer <MY TOKEN>';
$hdr[] = 'Content-type: application/json';
curl_setopt($curl, CURLOPT_HTTPHEADER, $hdr);
curl_setopt(
$curl,
CURLOPT_URL,
'https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$events = curl_exec($curl);
print_r($results);
But the status=live parameter is not taking effect and all events including drafts are being returned.
Has anyone successfully achieved a list of live events using EventBrite's API and if so, can you advise me how you managed and where I went wrong?
I'm unsure if I just helped you via email, but after troubleshooting I've deducted that this will only return 'live' events if you also pass in 'started' as a status parameter.
Ex.) 'https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live,started'
I hope this helps!
For the benefit of anyone else with a similar problem, the issue was the "Content-Type" header. Remove this, and all is well with the world.

How can I get a unique identifier associated with a meetup access token?

I have implemented a simple api in python to get an OAuth2 access token from a user in meetup. How can I get a unique identifier from that user, using the access token, other than the token itself? For example, if I'm given an access token, how can I get that users email address?
You can make a call to https://api.meetup.com/2/member/self.
PHP example with cURL library:
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, 'https://api.meetup.com/2/member/self');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: bearer ' . $accessToken
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$userData = json_decode($result);
You can get the ID from the user like $userData->id. As far as I know E-mail is not provided by this API call, at least not as a default anyway.
according to the docs here: http://www.meetup.com/meetup_api/docs/2/member/#get you should ask for the e-mail address by passing in the "fields=email" request parameter and this will return the e-mail address only if the following conditions are met:
email: Member's email address, if requested in fields parameter. This item is
only included if the currently authenticated user is the founder of a
Meetup Everywhere in which the member has elected to share an email
address.

How to check whether a username is being used on Twitter without being rate limited?

There are many REST API methods to check if a username is being used on Twitter but as far as I researched all of them are rate limited.
The reason I want this feature is to prevent someone from claiming a username on a website that someone else uses on Twitter, for example someone might claim a celebrity's username and confuse people.
It's impossible to use oauth in this scenario, since the user in this scenario might not be a Twitter user.
[150/hour rate limit is unacceptable. A possible solution would be to use Bing Search API to search for the username? - If Bing Search is not rate limited of course]
Try curl, here is minimal working script in php:
$url = "http://mobile.twitter.com/justinbieber";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$resp = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($code == 200)
{
echo "He is on twitter";
}
else
{
echo "He is on not twitter";
}
You should query mobile.twitter.com instead of real one, because real one doesn't do HTTP response codes. and few more reasons.

Update Twitter Status using CURL

I have a problem while updating twitter status by username and password.
Here is the Code for that:
$username = 'username';
$password = 'password';
$message = 'Testing';
$url = 'http://twitter.com/statuses/update.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //basic authentication
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
echo $buffer;
This is not for only one user so that I can not use OAuth(means using consumer key and other token). I have already tried this: http://www.1stwebdesigner.com/tutorials/how-to-update-twitter-using-php-and-twitter-api/ but i can not pass multiple user's username and password for updating multiple twitter status.
Please help me on this.
You won't be able to update twitter status by username and password via curl any more - basic authentication was deprecated/turned off by Twitter several months ago (August 2010). Updates and such by third party applications now have to be done via oauth authentication.
By the way - considering you're using PHP - I'd suggest using either the PEAR Services_Twitter package or the Zend equivalent.
You can not use user name and password to update a Twitter status no matter how many users you have. This no longer works. It has been turned off. You must use OAuth. OAuth allows multiple users to log into Twitter on your site. When they do that, you get a copy of their OAuth tokens. You then use these tokens to send tweets to their accounts. You will still find documentation for using basic authentication to do this online, but all of these are out of date. Basic authentication is no longer available on Twitter.
First you have to use cookie each time you update user status, then destroy cookie after each success status update.
Second, put this condition in loop to update all user's you wont.
See this may help you:
http://blancer.com/tutorials/73877/how-to-authenticate-users-with-twitter-oauth/

Resources