I am unable install MOODLE in localhost as it gives following error:
Can not initialize PHP session, please verify that your browser accepts cookies.
I tried to find the solution but was unable to come up with any. I've also referred this, still I'm stuck with the same problem.
I had a whitespace in my localhost URL path. Removing it (and updating $CFG->wwwroot in config.php) fixed this issue for me.
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
I am trying to simply use file_get_contents() to get content of http://www.google.com/search?hl=en&tbm=nws&authuser=0&q=Pakistan with same code on 2 different servers. One is getting every thing file while other is getting 403 error. I am unable to know what exactly the reason is. I used phpinfo() on both servers.
One difference I observe is that one use apache2 while other use some other HTTP server named LiteSpeed V6.6. But i don't know how if it affect this file_get_contents() method. For more detail you can see their phpinfo() page link below.
Where file_get_contents getting 403 the phpinfo is; http://zavahost.com/newsreader/phpinfo.php
while where it is working file , here is the phpinfo: http://162.243.5.14/info.php
I will be thankful if someone can tell that what is effecting file_get_contents()? Please let me know if any idea?
403 is an Unauthorized Error. That means you lack sufficient permission to connect to the content at that server. I'm not sure if this could be due to the inability to fetch data from your hosting provider, but it could also be denied based on header information the remote server has flagged as unauthorized.
Try using the answer on this post: php curl: how can i emulate a get request exactly like a web browser? to curl the same data from the server that is getting the 403
I am trying to make a request from Java (Android) to send a URL to a php file hosted on a web server.
wv.loadUrl(baseurl + "?url=" + URLEncoder.encode(url,"UTF-8"));
where wv is a web view.
The url generated using the above command is:
http://divu.in/TheRedDevil/readhtml/index.php?url=http://www.manutd.com/en/News-And-Features/Football-News/2013/Oct/jimmy-nicholl-knows-jonny-evans-will-battle-for-place.aspx
I also manually tried to open this link using browser and in both cases I got a 403 forbidden error.
Is it a hosting security issue or I am doing something wrong ?
How can this be solved ?
As others have suggested it is not a problem with Android, it is a problem with your PHP code or host.
It seems like your host somehow disallows loading external files.
If you are using file_get_content to load the external content you might try using curl instead - maybe they don't block that.
<?php
$curl = curl_init('http://www.example.com');
$result = curl_exec($curl);
echo $result;
?>
That URL returns 403 (FORBIDDEN) even with a standard desktop browser. It's got nothing to do with Android. The problem lies with the server/hosting configuration.
From all the research I did in the past hour, I realised that it is the apaches mod_security settings applied by hostgator.com (the providers).
So, for this particular application, I used post to send data from android app to the server and it worked like a charm.
Anyone working on Android app facing such problem may simple use POST request like:
wv.postUrl(baseurl,EncodingUtils.getBytes("url=" + url, "utf-8"));
I'm using Janrain's PHP-OpenID 2.1.3, and I've managed to get it working with all the providers I have tried except for Google and Yahoo. The major difference here seems to be that Google and Yahoo, unlike most other providers, don't use a user-specific URL, but rather have the user discovery framework all on their end - which throws the default Janrain framework for a loop then it tries to begin the auth request.
From what I've seen it looks like it's probably the YADIS discovery that is throwing the error, which should be able to be bypassed since the discovery is on Google or Yahoo's end, but I'm not sure. This is all a big informal learning experience for me, and I haven't had any luck finding documentation that can help me on this one. Any tips would be greatly appreciated.
Edit: the specific problem I am having is that when the begin() function is called for the Google or Yahoo URL, I get a null return. This function is found in Auth/OpenID/Consumer.php for reference.
Ok, I finally got to fix the library... I explained everything here (you can also download the php-openid library after my changes).
I needed to do what Paul Tarjan suggested but, also, I needed to modify the Auth_OpenID_detectMathLibrary and add the static keyword to a lot of functions. After that It seems to work perfectly although it is not an ideal solution... I think that someone should rewrite the whole library in PHP 5...
I had the same problem on Windows XP. Fixed by activating curl extension. To do this uncomment in php.ini the line
extension=php_curl.dll
by removing the ; in front of it if any. Restart apache.
Also on windows to work properly you need to define Auth_OpenID_RAND_SOURCE as null since in windows you don't have a random source. You can do this by adding the line
define('Auth_OpenID_RAND_SOURCE', null);
in CryptUtil.php before the first code line
if(!defined('Auth_OpenID_RAND_SOURCE')){
Even if the curl is not enabled the API should work by using instead the Auth_Yadis_PlainHTTPFetcher to communicat via HTTP. In the case of Google and Yahoo you need https, so it only works if open_ssl is enabled (Auth_Yadis_PlainHTTPFetcher::supportsSSL must return true).
I had exactly the same problem and it took me nearly 2 hours to track the problem. Jan Rain's OpenId lib requires 'DOM or domxml PHP XML' (https://github.com/openid/php-openid) but it will fail silently when neither is available!
On my CentOS installation simple:
yum install php-xml
fixed the problem (I'm using this repo: http://blog.famillecollet.com/pages/Config-en).
Are you using the example RP? Can I suggest you submit a detailed bug at http://trac.openidenabled.com/trac/newticket?project=php-openid or a detailed enquiry via the mailing list.
The immediate_mode support indeed does work the libraries if implemented correctly. I (and others) would also be happy to help you on the OpenID IRC channel irc.reenode.net in #openid. My nickname is flaccid.
It's because you don't have curl support enabled enabled in php. Without this, it can't get https content. At least, that's what I discovered. When I tried to get yahoo or google, it failed with an error message "Authentication error; not a valid OpenID," but when I enable php_curl, it works properly.
Make sure your server has curl with https protocol enabled. This solved it for me.
see this thread.
Here is a quick script to test it out. Upload on your server then acccess it via your browser.
<?php
error_reporting(E_ALL);
// create curl resource
$myurl = 'https://<YOURACCOUNT>.myopenid.com';
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL, $myurl);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
if (empty($buffer))
{
print "Sorry, cannot access $myurl .<p>". curl_error($curl_handle);
}
else
{
print $buffer;
}
curl_close($curl_handle);
?>
If it returns " Protocol https not supported or disabled in libcurl" then you know what to do.
I tried it using my gmail account and it works but it leads to a 301 permanent rediret, which makes sense.
Another potential difference is that Google and Yahoo use HTTPS and if your PHP or SSL installation is misconfigured (perhaps missing CA certs) then your OpenID code will fail to establish an association or complete the check_authentication call.
But without error messages or logs, I can't really tell what type of failure you're looking at.
A couple of years too late, but this might be relevant for users using Janrains PHP OpenID 2.2.2 library on a Windows platform. I'm still on PHP 5.2.17.
My simple test, just to make sure the library was contacting Google was to use the examples/discover.php program, and pass Googles OpenID URL (https://www.google.com/accounts/o8/id).
As per the instructions, the standard steps are to enable GMP (uncomment extension=php_gmp.dll) and CURL (uncomment extension=php_curl.dll). XML should already be enabled.
You may also need to extract the package in contrib/google and make sure google_discovery.php and ca-bundle.crt are in Auth/OpenID.
The extra paranoid could start with examples/detect.php, to make sure they have things set up correctly. It is expected you'd pass all the tests except the Cryptographic Randomness test. For this, you'll need to add
define('Auth_OpenID_RAND_SOURCE', null);
to the top of examples/detect.php. And while you're there, add that to examples/consumer/common.php (since examples/discover.php uses it).
Now, even after all this, discovery for the Google OpenID URL was failing. I was getting CURL error (60): SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in the php error log.
In the Windows environment, you need a definition for the CURLOPT_CAINFO. For my quick test, I added curl_setopt($c, CURLOPT_CAINFO, dirname(__FILE__)."/../OpenID/ca-bundle.crt"); before the curl_exec() statements in Auth/Yadis/ParanoidHTTPFetcher.php.
This allowed the examples/discover.php to discover the services offered by the Google URL.
As a longer term solution for setting CURLOPT_CAINFO in Windows, you might like to refer to this StackOverflow answer so you can add a setting to your php.ini.