הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   PHP| בעיה בSSL Socket - PayPal (https://hosts.co.il/forums/showthread.php?t=86496)

MasterNetwork 29-11-10 15:24

PHP| בעיה בSSL Socket - PayPal
 
אני מנסה לקרוא אתר כלשהוא בעל אבטחת SSL ויש לי בעיות בחיבור אליו.

זה השגיאה:
קוד:

HTTP/1.1 400 Bad Request
Date: Mon, 29 Nov 2010 13:32:55 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

וזה חלק מהקוד של הפונקציה לשליחה:

קוד:

$host = 'ssl://www.paypal.com';
$socket = fsockopen($host,443,$errno,$errstr,30);
if ( $socket )
{
    $request = "GET {$path} HTTP/1.1\r\n";
    $request .= "Host: {$host}\r\n";
    $request .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; he; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729)\r\n";
    $request .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
    $request .= "Accept-Language: he,en-us;q=0.7,en;q=0.3\r\n";
    $request .= "Accept-Encoding: gzip,deflate\r\n";
    $request .= "Accept-Charset: windows-1255,utf-8;q=0.7,*;q=0.7\r\n";
    $request .= "Keep-Alive: 115\r\n";
    $request .= "Connection: keep-alive\r\n";
    $request .= "Cookie: {$cookies}\r\n";
    $request .= "Connection: close\r\n\r\n";
    fwrite($socket,$request);
$info="";
    while ( !feof($socket) )
    {
        $info .= fgets($socket,128);
    }
return $info;
    fclose($socket);
}


Sagi 29-11-10 15:52

ניסית?

ציטוט:

$host = 'www.paypal.com';

Tomer 29-11-10 16:02

ציטוט:

נכתב במקור על ידי MasterNetwork (פרסם 787463)
אני מנסה לקרוא אתר כלשהוא בעל אבטחת SSL ויש לי בעיות בחיבור אליו.

זה השגיאה:
קוד:

HTTP/1.1 400 Bad Request
Date: Mon, 29 Nov 2010 13:32:55 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

וזה חלק מהקוד של הפונקציה לשליחה:

קוד:

$host = 'ssl://www.paypal.com';
$socket = fsockopen($host,443,$errno,$errstr,30);
if ( $socket )
{
    $request = "GET {$path} HTTP/1.1\r\n";
    $request .= "Host: {$host}\r\n";
    $request .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; he; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729)\r\n";
    $request .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
    $request .= "Accept-Language: he,en-us;q=0.7,en;q=0.3\r\n";
    $request .= "Accept-Encoding: gzip,deflate\r\n";
    $request .= "Accept-Charset: windows-1255,utf-8;q=0.7,*;q=0.7\r\n";
    $request .= "Keep-Alive: 115\r\n";
    $request .= "Connection: keep-alive\r\n";
    $request .= "Cookie: {$cookies}\r\n";
    $request .= "Connection: close\r\n\r\n";
    fwrite($socket,$request);
$info="";
    while ( !feof($socket) )
    {
        $info .= fgets($socket,128);
    }
return $info;
    fclose($socket);
}


קוד:

$host = 'ssl://www.paypal.com';
אני לא בטוח אם אפשר להתחבר דרך ssl:// או שחייב https://

אבל בכ"מ, אני גם לא רואה שהגדרת את $path - אתה שולח GET ואז תוכן ריק ולכן מקבל בחזרה Bad Request.

MasterNetwork 29-11-10 16:22

הגדרתי path וגם cookies זה לא קשור..
ואין דבר כזה https זה ssl ..

Tomer 29-11-10 16:56

ציטוט:

נכתב במקור על ידי MasterNetwork (פרסם 787471)
הגדרתי path וגם cookies זה לא קשור..
ואין דבר כזה https זה ssl ..

ראשי התיבות של HTTPS זה HyperText Transfer Protocol Secure ואיתו ניגשים לאתרי אינטרנט שמוצפנים עם SSL.

אני לא בטוח אם "SSL://" היא כתובת תקפה ב fsockopen. לדעתי לא, אבל אם אתה טוען שכן - בכיף.

תנסה להסיר את השורות הבאות:
קוד:

$request .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$request .= "Accept-Language: he,en-us;q=0.7,en;q=0.3\r\n";
$request .= "Accept-Encoding: gzip,deflate\r\n";
$request .= "Accept-Charset: windows-1255,utf-8;q=0.7,*;q=0.7\r\n";
$request .= "Cookie: {$cookies}\r\n";
$request .= "Connection: close\r\n\r\n";

ותריץ שוב. תראה אם זה פותר לך את הבעיה.

בניה 29-11-10 17:19

הצעה שלי, תעבוד עם CURL
http://php.net/manual/en/ref.curl.php

MasterNetwork 30-11-10 15:38

אני משתמש עכשיו בCURL הצלחתי לשלוח את הבקשה אבל אני לא מצליח לשלוח קוקיז רק לקבל אותם למישהו יש את הקוד ששולח קוקיז?

Sagi 30-11-10 15:53

ציטוט:

curl_setopt($var, CURLOPT_COOKIEFILE, $file_cookie);
curl_setopt($var, CURLOPT_COOKIEJAR, $file_cookie);
...

MasterNetwork 30-11-10 20:20

ונגיד הגדרתי את הקובץ לcookie.txt איך הוא בדיוק אמור להראות?
הכנסתי שם עוגיות בצורה רגילה..
נגיד:
קוד:

username=master; password=12345
וזה לא עובד, אתם מוכנים לפרט?


כל הזמנים הם GMT +2. הזמן כעת הוא 03:16.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ