I need to get the code from this msg using php
and username changes according to user
Web login code. Dear username, we received a request from your account to
log in on my.telegram.org. This is your login code:
nJB2G5Yb8Rs
Do not give this code to anyone, even if they say they're from
Telegram! This code can be used to delete your Telegram account. We
never ask to send it anywhere.
If you didn't request this code by trying to log in on
my.telegram.org, simply ignore this message.
<?php
$text = "Web login code. Dear username, we received a request from your account to log in on my.telegram.org. This is your login code: nJB2G5Yb8Rs
Do not give this code to anyone, even if they say they're from Telegram! This code can be used to delete your Telegram account. We never ask to send it anywhere.
If you didn't request this code by trying to log in on my.telegram.org, simply ignore this message.";
preg_match('~Dear ([^,]+),.* login code: (\S+)\s~isU', $text, $output);
list($dummy, $username, $loginCode) = $output;
echo 'Username: '.$username.' Login Code: '.$loginCode;
?>
Related
I am using WhatsApp Chat-API.
For registration process I follow the documentation as provided at
Documentation.
So for registration process I use the below code
$username = "mynumber";
$debug = true;
$r = new Registration($username, $debug);
$r->codeRequest('sms');
Now till here I get the msg for verification but the problem is how I can use code received on phone as next line of code is as given below
$code = '123456';// this is hard coded in documentation how i can use my verification code which i received on my phone
$r->codeRegister($code);
So after getting verification code how I use the above code to get login password?
What I did was to comment out $r->codeRegister($code) during the first run. Then I wait for WhatsApp to send the code. When I get the code on my phone, I comment out $r->codeRequest('sms') and uncomment$r->codeRegister($code); replacing$code` with the code the WhatsApp API sent.
It's a hackneyed way of doing this but it works.
Ideally, you should get $code from STDIN which waits for the user to type it in.
In my PHP project I want to integrate SMS gateway.
I have integrated HSPSMS SMS gateway.
They have given one API for this,but unfortunately I am unable to call this in proper way. I have called API after user successfully registered to site for sending SMS to user regarding same to notify he had successfully registered. Currently I am sending SMS for same but API's can send response back for SMS delivery(Successfully SMS sent or not in a JSON format).
Here is a problem- I am unable to caught the return response of SMS gateway,so it causes the Response is showing on user/Web Page.
It is a problematic for user.
For calling SMS gateway I have used PHP Header function like:
header("Location:URL of SMS Gateway");
My Code as Bellow,
<?php
include("otherpages/connection.php");
if(isset($_POST['submit1'])) {
$mname=$_POST['mname'];
$cdate=$_POST['cdate'];
$maddress1=$_POST['maddress'];
$mschool=$_POST['mschool'];
$mkendra=$_POST['centrename'];
$mmobile=$_POST['mmobile'];
$user=$_POST['user'];
$pass=$_POST['pass'];
$approved="0";
$qr="insert into tempregistration values('','$cdate','$mname','$maddress1','$mschool','$mschool','$mkendra','$mmobile','$user','$pass','$approved')";
// Code for Registration SMS
$url = 'http://sms.hspsms.com/sendSMS?username=#USERNAME#&message=Dear User,You Have Succeffully Registered to ABC.com ,Thanks&sendername=HSPSMS&smstype=PROMO&numbers=9503808004&apikey=#APIKey#';
header("Location:$url");
?>
Please help me on same or guide where I am doing right or wrong?
Any help will be appreciable.
You're sending the user's browser to the API, what you want to do is have PHP make the request and then tell the user if it was successful or not.
You may be able to use get_file_contents, but curl will give you more control.
You should have a function that will send the request to the API and return a success/failure and then display a message to the user.
Something like this (untested):
if(isset($_POST['submit1'])) {
$mname=$_POST['mname'];
$cdate=$_POST['cdate'];
$maddress1=$_POST['maddress'];
$mschool=$_POST['mschool'];
$mkendra=$_POST['centrename'];
$mmobile=$_POST['mmobile'];
$user=$_POST['user'];
$pass=$_POST['pass'];
$approved="0";
$qr="insert into tempregistration values('',
'$cdate','$mname','$maddress1','$mschool',
'$mschool','$mkendra','$mmobile','$user','$pass','$approved')";
//update to encode parameters which contain spaces
$message = urlencode('Dear User, You have successfully registered ...');
// other parametes might also contain spaces ...
$username = urlencode('#USERNAME');
$sendername = urlencode('HSPSMS');
//etc
$url = 'http://sms.hspsms.com/sendSMS?username='.$username
.'&message='.$message
.'&sendername='.$sendername
.'&smstype=PROMO&numbers=9503808004&apikey=#APIKey#';
if ($result = do_api_call($url)){
echo "SMS API returned:<br>";
echo $result;//for debugging
}else {
echo "Failure"
}
}
...
function do_api_call($url){
//this is very simplistic code to get you going ...
//use curl instead for more control
return file_get_contents($url);
}
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
How to get email id of the user who accepted my Twitter application?
I have gone through lot of forums. But they have mentioned, it is not possible. Also those posts are older than a year. May I know whether it is possible to get the user email id through twitter API using PHP?
I am getting Twitter user details using the following URL:
https://api.twitter.com/1.1/account/verify_credentials.json
This is now possible by filling out a form to request elevated permissions:
Go to https://support.twitter.com/forms/platform
Select "I need access to special permissions"
Enter Application Name and ID. These can be obtained via https://apps.twitter.com/ -- the application ID is the numeric part in the browser's address bar after you click your app.
Permissions Request: "Email address"
Submit & wait for response
After your request is granted, an addition permission setting is added in your twitter app's "Permission" section. Go to "Additional Permissions" and just tick the checkbox for "Request email addresses from users".
Note that user e-mail address has to be verified, otherwise Twitter refuses to provide it. (See include_email parameter description in elevated permissions doc page.)
Now you can fetch user email address from twitter API and it's a lot much easier. Just follow these steps...
Goto Twitter Apps
Click on 'Create New App'
Fill all required credentials and click on 'Create your Twitter application'
Now click on 'Permissions' tab -> check 'Request email addresses from users' field and click on 'Update Settings'. (check given picture)
Now in your PHP code, set all app details and add this code!
$params = array('include_email' => 'true', 'include_entities' => 'false', 'skip_status' => 'true');
$data = $connection->get('account/verify_credentials', $params); // get the data
// getting twitter user profile details
$twt_id = $data->id; //twitter user id
$twt_email = $data->email; //twitter user email
All Done.
Hope it help you, good luck. ;)
It is now possible to retrieve a user's email address from Twitter (if the user permits it, of course).
You'll need to apply to have your application white-listed to receive xAuth.
Check here for more info:
https://dev.twitter.com/rest/reference/get/account/verify_credentials
Yes you can get email address.This is now possible by filling out a some permission.
1.Go to this Link: https://apps.twitter.com/
2.After go to permission tab inside your created Application
3.Select Addition permission checkbox in your APP.
4.After successfully update setting you can get email address from Twitter.
If in some case you can not getting email address then please check your Oauth Api request url.
Your request url should be this type :https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true
It is not possible to get user's email address from twitter. You can see it here. You can open a form page on your callback page and get user's email address on that page. You can refer here for example usage
Here is how I have done this in ASP.Net using linqtoTwitter library
http://www.bigbrainintelligence.com/Post/get-users-email-address-from-twitter-oauth-ap
// call verify credentials api
var twitterCtx = new TwitterContext(authTwitter);
var verifyResponse =
await
(from acct in twitterCtx.Account
where (acct.Type == AccountType.VerifyCredentials) && (acct.IncludeEmail == true)
select acct)
.SingleOrDefaultAsync();
if (verifyResponse != null && verifyResponse.User != null)
{
User twitterUser = verifyResponse.User;
//assign email to existing authentication object
loginInfo.Email = twitterUser.Email;
}
I created a Facebook application to login and post to wall using my PHP application.
when I click on login link I am getting error "Logging in will not add this app's activity to Facebook" and not prompt the permission request step.
EDIT:
I just created a application and when I going to following url it's not prompt "Request for Permission".
it's prompt "Logging in will not add this app's activity to Facebook" error.
https://www.Facebook.com/dialog/oauth/?
scope=publish_stream,publish_actions,read_stream&
client_id=xxxxxxxxxxxxx&
redirect_uri=http://xxxxxx.xxx/post_to_wall.php&
response_type=token
I think Issue is with your URL. refer below URL with is I'm Using and Working absolutely fine.
$facebook_link = "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=".$app_id;
$facebook_link .= "&redirect_uri=".$url."/settings";
$facebook_link .= "&scope=publish_stream,offline_access,manage_pages";
Try it. may Help you. good luck.
Thanks.