I am using Quickbooks PHP API and it is working fine when we set allow_url_fopen to true.
But when we set allow_url_fopen to false then this API is not
working.
I found that fetch function of OAuth library is not getting any
response.
When I debug, it gives error like this "Fatal error: Uncaught
exception 'OAuthException' with message 'making the request failed
(dunno why)' "
For use OAuth, we have to set allow_url_fopen to true?
allow_url_fopen allows functions such as fopen, fsockopen to be URL aware, as a result, these functions can read remote data. If you turn this setting off, these functions are no longer URL aware, which means you cannot use URL to open a file. I suspect the API is using these function(s) to allow for remote connections. This setting is a security feature, which stops your scripts from accessing remote files.
Related
This issue has been plaguing me for a few hours. I can access the wsdl perfectly fine in my browser and using curl, however PHP SoapClient returns an error when using the following code:
$ps_client = new SoapClient("https://ppds.hitpromo.net/productData");
Here is the error it's returning:
Fatal error: Uncaught SoapFault exception:
[WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://ppds.hitpromo.net/productData' :
failed to load external entity "https://ppds.hitpromo.net/productData"
I tried a variety of solutions including setting various options when calling the constructor but nothing seems to be working.
This ended up not being the actual fix, it was happening because SSL was not enabled in php. I fixed it by commenting out this line in php.ini:
extension=openssl
In my case, I was able to construct the SoapClient using the http uri, however it threw an error when calling functions because SSL was not enabled.
OLD ANSWER:
Turns out this was a really simple fix. I'm not sure why, but changing it from https to http fixed everything:
$ps_client = new SoapClient("http://ppds.hitpromo.net/productData");
Really frustrating issue, because I've been playing around with this same WSDL on java and did not run into this while using ksoap. I wanted to post it because I'm sure someone might have the same problem some day.
This error occurs because your site is on a host whose firewall prevents swaps.
Contact your host company to add the IP of the swap site to the firewall whitelist.
You do not need to delete ssl or coding to ignore it.
I'm trying to use curl in the google app engine, but it gives this error:
Uncaught Error: Call to undefined function curl_init()
HP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/curl.so' - /usr/lib/php/20151012/curl.so: cann
ot open shared object file: No such file or directory in Unknown on line 0
ERROR:root:php failure (255)
I searched, and found that the curl is disabled, and that i had to create a php.ini file with this code inside:
extension = "curl.so"
I also read that it could be a problem of versions of the service, so i did it in the getting started of the app engine(first version).but it did not work.
But it seems that the php.ini is not recognized by the app engine,someone could help me how could i POST using curl or another way
There are two things that you should also keep in mind:
cURL is only available for applications with billing enabled as stated in the documentation.
In your php.ini you have both cURL and cURLite enabled which is incorrect. Only one of those can be enabled and not both at the same time.
You can deploy sample application following the steps provided, which will get you started using cURL with PHP in App Engine Standard.
For other methods of issuing HTTP(S) requests using PHP, refer to the documentation here.
I've done extensive testing, enabled verbose cURL logging (Leaves no logs, gives a generic cURL error #7), tried using the built in handlers through file_get_contents. (Also errored, see below) It seems no matter what if I attempt to request information from anything on the roblox.com domain from my app it gets errored before it can even try. I know it is not the distant end as multiple other sites are working fine aswell as I've used an alternate host to try the same communications that I'm doing with Google App Engine and it worked without any issue. At this point I can only conclude that Google has banned my app from communicating with the ROBLOX website without giving me any indication of any kind. If this is true, why is my app banned, and more importantly, why wasn't I alerted?
cURL output with verbose logging enabled:
https://api.roblox.com/users/get-by-username?username=christbru01
CURL Failed with error #7:
CURL HTTP CODE #0
CURL INFO: 0
This is the code which generated these:
syslog(LOG_DEBUG,(string)$newurl);
syslog(LOG_WARNING,'CURL Failed with error #'.curl_errno($s).": ".curl_error($s));
syslog(LOG_DEBUG,'CURL HTTP CODE #'.curl_getinfo($s,CURLINFO_HTTP_CODE));
syslog(LOG_DEBUG,'CURL INFO: '.curl_getinfo($s,CURLINFO_HTTP_CONNECTCODE));
file_get_contents output:
file_get_contents(https://api.roblox.com/users/get-by-username?username=Christbru01): failed to open stream: Connection error
This is the code which generated this:
echo file_get_contents("link removed due to insufficient reputation");
You need to enable cURL in your instance by adding google_app_engine.enable_curl_lite = "1" to your php.ini file.
https://cloud.google.com/appengine/docs/php/config/php_ini
The MSDN forums have not been very helpful so I am reposting my question here.. I am trying to use the new Windows Azure SDK for PHP to download a blob using
$blobRestProxy =
ServicesBuilder::getInstance()->createBlobService($connectionString);
$blob = $blobRestProxy->getBlob($container, $blobname);fpassthru($blob->getContentStream());
The problem is that in the WindowsAzure\Common\Internal\Utilities.php file stringToStream() is returning a warning which causes the download to fail when allow_url_fopen is Off:
PHP Warning: fopen(): data:// wrapper is disabled in the server
configuration by allow_url_fopen=0
My question is whether this is an isolated problem or does the new SDK require allow_url_fopen to be On in order to use the getBlob function? Is there an alternative where I can avoid having to turn on allow_url_fopen?
The SDK uses fopen for REST API queries (also for Blob requests). Because REST APIs have a URI Scheme, you need allow_url_fopen to be turned ON.
What kind of alternative are you looking for? The only alternative I see, is to modify the SDK code to avoid the usage of fopen. Maybe with cUrl? But I would not recommend it either...
I'm trying to call a Soap Client for testing purposes from the same server that I'm running the service on. My WSDL is at: http://www.installittoday.com/api/server.php?wsdl I'm trying to load it simply with:
$client = new SoapClient('http://www.installittoday.com/api/server.php?wsdl');
but I get back the error:
Warning: SoapClient::SoapClient(http://www.installittoday.com/api/server.php?wsdl) [soapclient.soapclient]: failed to open stream: Connection timed out in /home/installi/public_html/api/client.php on line 4
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://www.installittoday.com/api/server.php?wsdl" in /home/installi/public_html/api/client.php on line 4
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.installittoday.com/api/server.php?wsdl' : failed to load external entity "http://www.installittoday.com/api/server.php?wsdl" in /home/installi/public_html/api/client.php:4 Stack trace: #0 /home/installi/public_html/api/client.php(4): SoapClient->SoapClient('http://www.inst...') #1 {main} thrown in /home/installi/public_html/api/client.php on line 4
Yet I can set up the client just fine from another site of mine. Is this a firewall issue or what?
Make sure these extensions are enabled in your php.ini
extension=php_curl.dll
extension=php_openssl.dll
extension=php_soap.dll
Also loading from here fine.
Try connecting to it from the site you want the client on with a web browser, or if its a remote machine with no proxy set up use curl:
curl http://www.installittoday.com/api/server.php?wsdl
That will tell you if you can even get a connection to that site via the machine.
You could also try multiple connects, or increasing default_socket_timeout if your machines connection speed is limited/congested.
What ports are you trying to connect over?
For anyone coming across this error. Try disabling the WSDL cache, either from your php.ini or a parameter in your SOAP call.
The problem is, PHP by default caches the WSDL file in the temp folder. After the file is first cached, PHP keeps on using this file. It is only refreshed after 24 hours (the default ttl for the cache).
So if you change your WSDL file, PHP will pickup the old one, resulting in an error like the OP. Matt, your problem was solved by using referencing a file that is never cached.
The reason it is cached by default because your server has to request the file and then parse it, which takes a bit of fetching and processing.
You have two options, either amend the relevant variable in your php.ini or send a param along with your SOAP call.
For example:
$client = new SoapClient($webservice, array('classmap' => $soap_class_map, 'cache_wsdl' => WSDL_CACHE_NONE));
Hope this helps.
OP again here.
A little more context: I'm hosting the service (obviously) on installittoday.com. I'm also trying to run a client from the same place just for testing purposes. I can connect to the service from literally every other site I've tried perfectly fine, and I've successfully opened a few WSDLs with the Client hosted on installittoday. It seems the site can't connect to itself for some reason.
I sincerely doubt it's a congested line issue.
Now that I've gotten this far I realize this problem probably extends beyond SOAP to some kind of Apache configuration issue, unless there's a port thing that I'm missing. I haven't set up any ports differently, is there one I should make sure I have open for SOAP?
I solved this problem by saving the dynamically generated nusoap WSDL as a standalone file and all seems to be working just fine. I have no idea why this would be the case.
I'm planning to move it to PHP5 anyway, I was just using nuSoap to generate the WSDL.