My user logs into my app, app sends idtoken to my server, server sends request to google, google sends userdata to my server, server puts it in my db. worked fine for 5 Months.
Now:
If I type in my webbrowser
https://www.googleapis.com/oauth2/v3/tokeninfo?id_token= (+ idtoken of my google account extracted from my app)
I'll get the json with my name and so on in milliseconds as it should be.
today, since 6 hours, if my phpfile runs the command
$url = "https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=".$idtoken;
$str =file_get_contents($url);
The page is loading and loading and finally returns no value.
I tried this version to get the .json file
$ch = curl_init($url); // such as http://example.com/example.xml
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$str= curl_exec($ch);
curl_close($ch);
no fix with that.
I cannot install composer because no root access.
I contacted customer support, they told me everything is fine on the serverside.
If after checking on the server's console that you can't curl to it over SSL, but can otherwise, it would suggest the port is blocked. Ask the hosting provider to open it.
Related
I found out that I can get latest user posts in JSON format with a simple CURL request to
https://www.instagram.com/some_nickname/?__a=1
So I am trying:
$url = 'https://www.instagram.com/some_nickname/?__a=1';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
The code works fine on my local machine and returns a JSON array, from which I get the latest posts of a user. The problem is that the very same code returns empty string from any of my remote servers (I've tried 3 different web-hosting providers).
Please, advice.
Instagram blocked the ranges of IP hostings. I have seen the following information:
Instagram has started applying extremely restrictive limits to
requests from IPs that are detected as cloud servers.
A couple of requests will go through at first, but after a moment, all
requests will be blocked, with a very long timer until they are
unblocked again. After this timer, you get a couple more requests, and
the cycle repeats.
Since websites must be hosted in the cloud, any interaction with
Instagram becomes extremely difficult if the cloud provider is on
Instagram's block list. All the cloud providers I've tried are on that
list.
You need to use proxy. But it will be a difficult task, because many proxy(in my experience) are also blocked
I have a weird scenario here. I have 3 servers:
1.) http://my-server1/test
--> This server url will only return a json object "test"
2.) http://my-server2/get_request
--> This url will send a request via PHP CURL method
3.) http://mylocal-machine-server/get_request
--> The same as my server2, only that, it is run on my local machine via XAMPP
The get_request method in both second and third server has the ff. simple code to test CURL:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com');
curl_exec($ch);
The two servers executed the request successfully and the content of google.com was displayed. Now, I changed the url from google.com to my server 1 url in get_request method for both server 2 and my local server, so it looks like this now:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://my-server1/test');
curl_exec($ch);
I run the get_request method on both the second server and my local server. The get_request on my local server was able to get the "test" json object. However, the get_request on my second server takes a while to load, and when it finished loading, it didn't display anything.
I found the culprit. The ip address of my second server is not whitelisted on the firewall of my first server (the url where I get the data). The second server time out because it has no access yet to the first server. I just realized this when I use the curl_error suggested by greeflas, and find that the error is connection time out.
i want to get data from remote API with curl but not works:
(im using ip board btw)
$url = "http://www.voobly.com/api/findusers/". $nick_list . "?key=" . $voobly_key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
this is the response i get:
Please enable cookies. One more step
Please complete the security check to access www.voobly.com
Why do I have to complete a CAPTCHA?
Completing the CAPTCHA proves you are a human and gives you temporary
access to the web property.
What can I do to prevent this in the future?
If you are on a personal connection, like at home, you can run an
anti-virus scan on your device to make sure it is not infected with
malware.
If you are at an office or shared network, you can ask the network
administrator to run a scan across the network looking for
misconfigured or infected devices.
Cloudflare Ray ID: 3b009b3171e55c09 • Your IP: 69.89.31.238 •
Performance & security by Cloudflare
anyone know how to solve this
API provider said i need to add a valid browser agent string + PHP cookie session but idk what wrong here :(
The web site you're trying to access has misconfigured Cloudflare to block bots from accessing their site… including the API.
You will need to contact them to have them disable this. There is no easy workaround -- the whole point of this feature is to prevent scripts from accessing the site.
I've tried to retrieve the image data of my Facebook profile picture, using both file_get_contents and curl.
The problem occurs on my Google compute engine instance, while on any other server (localhost - mamp, AWS) the script works fine.
An example for one of the scripts I was using
<?php
var_dump(
json_decode(
file_get_contents("https://graph.facebook.com/_FACEBOOK_ID_/picture?width=720&height=720")
)
);
Please keep in mind that I've tried using the parameter redirect=false, and accessing the image url I've got in my json response returned false as-well.
Also, I've tried using wget in SSH to the image's url, which returned (403) Forbidden.
My assumption is that I need to configure something differently in my server, not PHP, but because I'm able to retrieve any other image, with the same script - I'm not sure what.
I've already experienced this exact problem,
Ignoring SSL verification while using cURL did the trick for me.
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Ignore SSL verification
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/_FACEBOOK_ID_/picture?width=720&height=720");
$data = curl_exec($ch);
curl_close($ch);
var_dump($data);
I created a small web app, with the feature of being able to Sign in with a Twitter account, by connecting with OAuth. It worked like charm for a few months, but now it stopped working. This is a quick and summarized overview "Sign in with twitter" algorithm.
Collecting some parameters (timestamp, nonce, some kind of application ID and so)
Use this parameters to create a new URL that looks like this:
https://api.twitter.com/oauth/request_token?oauth_consumer_key=DLZZTIxpY19FnWJNtqw5A&oauth_nonce=1369452195&oauth_signature=DIetumiKqJu66XXVvDDHdepnP9M%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1369452195&oauth_version=1.0
Connect to that URL and retrieve the data, it has an access token
Continue doing fun stuff using that access token.
The URL generated in step 2 is fine because I tried manually copying it in Google Chrome, and it shows a beautiful access token, so the problem isn't there (I think).
In the step 3, I have a really small method that should do some very basic stuff: Connect to the URL generated before, retrieve the content and return it.
In my localhost Using EasyPHP 12.1, it works perfectly, as usual, but in the free host that i'm using (000webhost) it doesn't work anymore. When trying to connect, it just timeouts. The HTTPCodeError is 0 and the CurlError is "Couldn't connect to host".
This is the method used to connect to the URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
And this is an example of a URL used with that method:
https://api.twitter.com/oauth/request_token?oauth_consumer_key=DLZZTIxpY19FnWJNtqw5A&oauth_nonce=1369452195&oauth_signature=DIetumiKqJu66XXVvDDHdepnP9M%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1369452195&oauth_version=1.0
I've been trying to fix it all day long, but now I have no idea even of what to try. The files are the very same in my localhost and in the 000webhost.
If you could enlighten me I would be very happy. I'll take my pants off for answers if it's needed. Thank you very much.
It might be possible that Twitter has blacklisted (blocked) your free host's servers or IP address. This can happen if other users on the server abuse the API.
The only thing I can think of is that your free web hosting service blocks it. You know these services are perfect as long as everything is very simple. The moment things become complicated you run into restrictions implemented by the provider. Most of these services limit band width, disk space, server use, support, uploading and more.