Is it possible to make phone call using PHP and voice modem?
PHP will run on local server (XAMPP).
I have found some solutions for asp.net (using 3rd party api and software which is fine IMO), but PHP is required for this project.
You said a 3rd Party is okay, so this might be interesting for you.
Please note that you will need to signup for an account with Sonetel in order to use the api. While this is free, making phone calls cost few cents.
Here's an example code to use their api. The api is initiating two phone calls, one to you and one to the person you are calling. It will first ring the number provided first and if this call is picked up, it will ring the second number and then connects both together.
$url='https://call.sonetel.com';
$data = array('email' => 'abc#xyz.com','password' => 'XXXXXXXXX','call1' => 'XXXXXXXXXX','call2' => 'XXXXXXXXXXXXX');
$data_to_send = http_build_query($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_to_send);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$result = curl_exec($ch);
Related
I want to web scrape an instagram url so I can obtain the user thats making the post. I know that first to web scrape that url i need to sign in to instagram but the question is that i dont know how to sign in.
$data = array(
"username" => "*******",
"password" => "******"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.instagram.com/accounts/login/");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
$response = curl_exec($ch);
curl_close($ch);
echo $response;
What you are asking for is against Instagram's terms and conditions:
https://help.instagram.com/1188470931252371
We prohibit crawling, scraping, caching or otherwise accessing any
content on the Service via automated means, including but not limited
to, user profiles and photos (except as may be the result of standard
search engine protocols or technologies used by a search engine with
Instagram's express consent).
Guys, I am currently working on file hosting premium link generator basically it will be a website from where you can get a premium link of uptobox,rapidgator,uploaded.net and other file hosts sites without purchasing the premium account. Basically, We are purchasing the accounts of this website on behalf of the users and offering this service at a low price. So when I was setting up API of direct download link of rapidgator I was able to get that link but I was getting session is over. I was trying to that API via a software, not via manual coding and I am facing this problem
So I have been getting Rapidgator API reference from Tihs Site:- https://gist.github.com/Chak10/f097b77c32a9ce83d05ef3574a30367d
So I am doing the following Thing With My Debugging Software And I am getting success response but when I just open that URL in my browser it shows Session Id Failed.
So Here Are Steps What I am Doing
Sending a post request on https://rapidgator.net/api/user/login with username and data and I am getting this output
{"response":{"session_id":"g8a13f32hr4cbbbo54qdigrcb3","expire_date":1542688501,"traffic_left":"13178268723435"},"response_status":200,"response_details":null}
Now I am sending a get request (I tried Post Request Too But the Same Thing Happened) on this url with session id and URL embedded in URL https://rapidgator.net/api/file/download?sid=&url=
and I am getting this output
{"response":{"url":"http:\/\/pr56.rapidgator.net\/\/?r=download\/index&session_id=uB9st0rVfhX2bNgPrFUri01a9i5xmxan"},"response_status":200,"response_details":null}
When I try to download the file from the Url through my browser It says Invalid Session and sometimes too many open connections error
Link of the error:- https://i.imgur.com/wcZ2Rh7.png
Success Response:- https://i.imgur.com/MqTsB8Q.png
Rapidgator needs its api to be hit three times with different URLs.
$cookie = $working_dir.rand();
$headers = array("header"=>"Referer: https://rapidgator.net");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://rapidgator.net/api/user/login");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=email#domain.ext&password=myplaintextpassword");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close ($ch);
$rapidgator_json = json_decode($result,true);
return array($rapidgator_json['response']['session_id'],$cookie);
http://rapidgator.net/api/user/login (this is the initial login)
Above link gives you a session id that you need. The response is in JSON
Now we need to request a download link that will allow us to download without having to log in to a human input form. So we will use its api to request a download link using the intial session id we got from the 1st url.
$headers = array("header"=>"Referer: http://rapidgator.net/api/user/login");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://rapidgator.net/api/file/download?sid=$rapidgator_session&url=$rapidgator_file");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $working_dir.$rapidgator_cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $working_dir.$rapidgator_cookie);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close ($ch);
$rapidgator_json = json_decode($result,true);
return array($rapidgator_json['response']['url']);
Basically, we pass the session id Rapidgator gave us assuming you have properly passed a valid account. Then we include the source url you had obtained (Link to file) http://rapidgator.net/api/file/download?sid=$rapidgator_session&url=$rapidgator_file
After that. Rapidgator will return a JSON response with an url that u can use to obtain the file in question. This allows you to use whatever download method you want
as that link is a session url is valid for a short period of time.
$rapidgator_json['response']['url']
All code above is somewhat incomplete. Some extra checks on the json responces for possible errors/limits are recommended. I used functions on my end but this is enough for you to see what you should be doing. Rapidshare API has other data that can be useful in determining if you have gone over your daily quota. How long the session url is going to last and so on.
I create a paypal plus (only avaible in germany) payment process via php and curl. I can successfully create a payment and in the next step paypal redirect me to my shop. At this point i want to check if the customer has changed the shipping address and what payment method he choosed. (paypal plus includes various payment methods like invoice)
I have a valid access token and try this piece of code:
$ch = curl_init();
$headers=array('Content-Type:application/json','Authorization:Bearer '.$access_token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "https://api.paypal.com/v1/payments/payment/".$_GET['paymentId']);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'SSLv3');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$json = json_decode($result);
I looked in the documentation and it looks right to me.
https://developer.paypal.com/docs/api/payments/#payment_get
The problem is the following. I dont receive information about the created payment with the submitted id($_GET['paymentId']). Instead of this i receive informations about my own payments made with this paypal accounts by other merchants.
What i am doing wrong?
It was my fault. The code is fully correct, but the $_GET var was empty, because of a mod_rewrite rule.
I am trying to design an Application which can create folder and retrieve that folder from box.com using PHP, I have tried lots of APIs but fail.
Also I want to create the folder with automatic authentication.
I have tried https://developers.box.com/docs/ but can't do automatic authentication.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.box.com/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_ENCODING,"Content-Type:application/x-www-form-urlencoded");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", 'Accept: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS,array('client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET_KEY&grant_type=urn:box:oauth2:grant-type:provision&username=MY_EMAIL'));
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
here i use my client id, secret key and my email id which are register in box.com
IT Gives Some Kind of error:
{"error":"invalid_client","error_description":"The client credentials
are invalid"}
I would recommend using this BoxPHPAPI. I have used it on a big enterprise app. You have to make sure first that you have a app created at developers.box.com.
Once that is done you can pass all that info to the BoxPHPAPI Class and it should handle your login and authentication.
If you plan on doing many API calls at once or rapid succession I recommended you use curl pooling. It speeds it up quite a bit. From about 4 seconds to under 1 (for 5+ API calls). You can see an example of the pooling in this fork of the BoxPHPAPI.
I hope this helps!
I'm a bit confused about API vs WebService. But anyway, which one will you follow to.. lets say to provide simple string or xml or json data return.
Currently i have implemented something like:
Server:
echo json_encode("hello, ".$_POST["q"]);
Client:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('q' => 'world!'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
$response = curl_exec($ch);
curl_close($ch);
Normally as the standard way, how do we even call/name it? Shall i name it API? Or WebService?
And in normal way (whenever we need to provide some data out of Server, like above) which one do we implement?