2016-07-15 2 views
0

ich dies getan hatte:wie curl Anfrage Json verwenden, um Remote-Site anmelden

<?php 
     $post_body = '{"login": "injoit", "password": "injoit"}'; 
     $cookie_file = tempnam('/temp', 'cookie'); 
     $ch = curl_init('remote server login here'); 

     curl_setopt($ch, CURLOPT_HEADER, 0); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_POST, 1); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); 
     curl_exec($ch); 

ich dies als Antwort bin immer: Failed to connect to "remote server url here" port 8002: Connection timed out(7)

Antwort

1

geben müssen versuchen
$cookie_file = tempnam('./temp', 'cookie'); 
    $post_fields = '{"login": "injoit", "password": "injoit"}'; 
    $ch = curl_init('http://api.quickblox.com/login.json'); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); 
    curl_exec($ch); 
+0

auch ' curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ CookieJarDateiname); ' um die SessionID zu speichern, die der Remote-Server Ihnen als Client gibt –

+0

@ Santa'shelper danke für Ihre Erinnerung – jaxon

+0

Ich hatte meine Frage als deine Antwort bearbeitet. Aber immer noch nicht funktioniert. Bitte helfen – Aashi