drupal_http_request returns error code

2019-07-27 05:40发布

I have three website Main ,a, b. If you logged in through "Main" website then i will enable session for websites "a", "b". So this is working fine. When user logged out of Main Website, i have to loggout of other two website "a", "b". There are two different logout url for the other two website so i am calling those two website's logout url in the Main website's logout function using drupal_http_request

Example CODE:

// this is the function where main website session are destroyed
function mymodule_logout(){ 

session_destory(); 

$request =  drupal_http_request("http://B-website.com:8083/VideoBook/signout.action");

print_r($request); 

if($request) { 
drupal_goto($logout_url,$options); 
}


}

OUTPUT :

stdClass Object ( [code] => 0 
[error] => Error opening socket ssl://mywebsite.com:8443 
[redirect_code] => 302 
[redirect_url] => https://mywebsite.com:8443/cas/login?service=http%3A%2F%2Fmywebsite2.com%3A8083%2FVideoBook%2Flogin.action )

B-website-logout-url : http://B-website.com:8083/VideoBook/signout.action

When i run this logout url in the browser tab , then all the session and cookies are destroyed , But when i run this logout url using drupal_http_request('http://B-website.com:8083/VideoBook/signout.action'); , then it results in error "Error Opening Socket ssl:// " . Thanks in Advance.

1条回答
趁早两清
2楼-- · 2019-07-27 06:26

Basically, the signout.action requires session data i.e currently logged in user details but we are not able to send the session data through the curl. so its redirecting to the login.action. So it results in error code 302.

查看更多
登录 后发表回答