Check if account exists by email (facebook) - php

How can I check if facebook account exists by typing email?
For example, if i go to http://mysite.pl/fb/?email=email#gmail.com and if account with this email exists on facebook, it returns "true", if not, returns "false".
Code I tried:
if(isset($_GET["email"])) {
$url = file_get_contents('https://www.facebook.com/search/results/?q='.$_GET["email"]);
echo '<pre>'.$url.'</pre>';
}
It's not working, returns info that my browser is not supported by facebook.

This is not something Facebook is going to enjoy you doing. If you want to try anyway, you need to set your request header to something that they'll think is a normal web browser. This will mean using cURL instead of just file_get_contents().
See this question for more information: PHP cURL custom headers

Related

Facebook Client OAuth settings domain not working with query strings

I'm trying to get the Auth working with Facebook but it keeps on telling me that my redirect URL is not working.
In the Valid OAuth Redirect URIs I have the following
https://localhost
The issue is that, I'm passing some additional query string to my callback, like
https://localhost?uuid=something&service=my_service
When attempting to Auth, I do get the request popup and then I get a redirect URL but then Facebook is telling me that the URL is not allowed.
If I test https://localhost?uuid=something&service=my_service in Facebook's Redirect URI Validator it's telling me it's not valid
How can I add a a URL including a dynamic query string ? I've tried
https://localhost*
But Facebook is telling me this is not a valid URL and won't let me save/add this URL.
#ceejayoz put me on the right track, I will answer my own question, that might help someone else.
Additional data must be passed in a state parameter such as
$data = json_encode($some_std_class);
$pdata = $fb_helper->getPersistentDataHandler();
$pdata->set('state', $data);
$login_url = $fb_helper->getLoginUrl($my_url, $my_permissions);

Why do I receive an error 500 when trying to access Paysafe Api server?

The Paysafe API was working perfectly fine in localhost, I was able to complete payment to Netbanx. I started to integrate the system on the website. I have a page for billing information, then a page for card payment where I use paysafe.js to create a token.
Then, I use PHP to get response from the server. This works in local. But online, this last part where I try to settle a payment, I get an error 500. I think it could be because the server is not using HTTPS. I want to know if it's possible that the error 500 is coming from the fact we don't have HTTPS or if it's something else?
P.S: It's complicated to access to the server because of bureaucracy, I don't want to make all the process if it's sure it's not that!
Thank you!
P.S.: I also tried using curl instead, and the response was bool(false).
require_once("config.php");
use Paysafe\Environment;
use Paysafe\PaysafeApiClient;
use Paysafe\CardPaymentService;
use Paysafe\CardPayments\Authorization;
$client = new PaysafeApiClient($paysafeApiKeyId, $paysafeApiKeySecret, Environment::TEST, $paysafeAccountNumber);
$info = new Authorization(array(
//PAYMENT ARRAY (Getting POST variable from previous page)
));
$response = $client->cardPaymentService()->authorize($info);
$statut = $response->status;
That Environment::TEST obviously does not match the production environment (or host-name).
Just enable PHP error reporting for your IP only, in order not to possibly leak any details.
Also check the console there (if any), if that host if even authorized to access the API.
I mean, HTTP500 is an error description just alike "it does not work".

Automated Yahoo Mail login with cURL - how?

I am currently attempting to create a page with cURL instructions that does the following:
Take the following link, send a GET request to it, and retrieve the results.
http://login.yahoo.com/config/login?login=xxxxxxx&passwd=yyyyyyyy&.done=http://m.yahoo.com/mail
xxxxx - username
yyyyy - password
Easy, right? Not really. Since the page that is to be returned, is designed to automatically log you in your Yahoo Mail inbox.
I tried with:
<?php
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://login.yahoo.com/config/login?login=xxxxxx&passwd=yyyyyyy&.done=http://m.yahoo.com/mail',
CURLOPT_USERAGENT => 'something-here'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
echo $resp;
?>
I do get a response, but all it's about is the Yahoo Mail login page. It doesn't actually execute the login and retrieve the related Yahoo inbox.
How would I go about doing that with cURL?
After some extensive testing.. I decided to see as why this was not working and I was interested in #Sammitch's comment that it won't work..
I first tried using my own HTTP Requests class to login and I failed. the response always stayed empty but if I visited the URL from my browser it would work. I turned on the developer tools in Chrome and went to the network section and tried logging in
It seemed that that page posted the data into another page which is
http://login.yahoo.com/config/login_verify2?login=xxxxxx&passwd=yyyyyy&.done=http://m.yahoo.com/mail
After altering my cURL code to work with that URL directly it signed me in.. so this is the solution to your question.. basically the URL you were using did not work and the one that should work is shown above.

trying to have user attend event via api

I'm trying to use Facebook's API code to have a user attend an event, but it's not working. I can run the post comment on my browser window but as a php script it's not working
$fields = array('access_token'=>$access_token);
$result = HTTP_POST("https://graph.facebook.com/4XXXXX663/invited?access_token=$access_token",// URL to query
$fields, // POST fields; associative array
USER_AGENT, // user-agent value
"", // cookie storage and retrieval
"", // proxy; type:ip:port[:user:pass]; supported types: http, socks5
true, // return the data or not
false, // include headers in the return data
"", // set value for REFERER header
true, // automatically follow "redirects" ("Location" header)
false); // enable or disable multipart post (if uploading, set to true)
You're passing access_token with the URL as well as the POST data.
Remove the ?access_token=$access_token part in your URL and try again.
Also it would be good if you could post the error you're getting, So we can see what's the actual issue and also make sure you post that HTTP_POST function so we can know if the cURL settings are correct (I'm assuming this function is using cURL).
EDIT 1: Removed, Just realized you're trying to attend an event and not invite.
Edit 2: You need to ask your users to give rsvp_event permissions in order to make them attend your event via your App. You also need to make an HTTP POST to EVENT_ID/attending (This is for attending the event) and not to EVENT_ID/invited (This is for inviting users/friends to your event).

Zend HTTP Client password

Im trying to connect from PHP(Zend Framework) code to an aspx Web Service. I need to send via post a few parameters to the page( email, password). I have tried to use Zend_Http_Client, and do this:
$client = new Zend_Http_Client('https://thesiteurl.asmx/Login');
$client->setMethod(Zend_Http_Client::POST);
$client->setAuth($username, $password);
$client->setParameterPost(array('email' => 'email', 'password' => 'password'));
$response = $client->request();
$this->view->response = $response;
where $username, $password are the username and password I use to log in to the web service(it has a pop-up window that asks me for username and password).
This code gives me the unauthorized page. So im asking where am I using the site username and password wrong? How can I use them?
edit:
The Auth is auth-basic.
Edit2:
I talked to the owner of the web service he says that everything is UTF-8 is this a problem, isnt it is a default? If not how do i do that?
You could check if a referer-header is needed, or it might be that it also needs a cross-site request forgery number. Simply dump the request that is made by your browser when you login and dump the request that your script is generating, compare those and it should work out.
For the browser-request dump you could use livehttpheaders plugin for firefox.
Depends on what that pop up box really is.
You probably need to study the HTTP Authentication. Currently, Zend_Http_Client only supports basic HTTP authentication. This feature is utilized using the setAuth() method, or by specifying a username and a password in the URI. The setAuth() method takes 3 parameters: The user name, the password and an optional authentication type parameter. As mentioned, currently only basic authentication is supported (digest authentication support is planned).
// Using basic authentication
$client->setAuth('shahar', 'myPassword!', Zend_Http_Client::AUTH_BASIC);
// Since basic auth is default, you can just do this:
$client->setAuth('shahar', 'myPassword!');
// You can also specify username and password in the URI
$client->setUri('http://christer:secret#example.com');
Source.
If this is not an HTTP auth and is somothing else, try to use cURL, wget or linx to see exactly what is happening on the page and now you can simulate it using Zend_Http_Client.
Sometimes you have to send cookies, execute some Js or follow some redirects. Zend_Http_client can do all this things.
have you tried this?
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Socket',
'ssltransport' => 'tls'
);
$client = new Zend_Http_Client('https://thesiteurl.asmx/Login', $config);
$client->setAuth('shahar', 'myPassword!', Zend_Http_Client::AUTH_BASIC);
also I am confused, is this popup a http basic auth, or something that is self designed?
since for basic auth you normally wouldn't send any post params...
the real URL of the site would help very much for finding the solution...
If you can access the servis using browser, use firebug to check the request and response. There might be some other parameters involved, eg cookie.
The best way to tackle these things is by just using the packet sniffer (tcpdump, ethereal, ...) to see what's happening on the line. Then compare the request/response you observe in a working scenario (e.g. from your browser) to the request/reponse which is not working.
This will very quickly reveal the precise difference at the HTTP level. Using this information you can either find out what to fix in your handling of Zend_Http_Client, or find out that Zend_Http_Client doesn't support a particular feature or authentication scheme.

Categories