last day (14 days later) » 

11:51 AM
2
A: PHP CURL Never Ending Request

Shakti PhartiyalThe url has an SSL error, so in the cURL request when cURL tries to verify the host it blocks you from accessing the address. use the following: curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); This is obviously insecure method to access the URL but ...

 
Ali
updated my question.
added your 2 lines as well, no luck yet.
 
any errors from curl?
 
Ali
page keeps on spinning, i think curl needs to finish its request before displaying any errors. in my case it seems like it's never going to complete.
 
I ran your code from the command line as well as from the browser.. It runs fine
It returns {"error":"unsupported_grant_type"}
 
Ali
yeah, it was working good on my localhost, it all happened when i put it live
 
11:51 AM
Check the error logs in your web hosts panel
 
Ali
ok
give me a second
 
Ali
i see nothing
 
cannot view the image.. The url is blocked
 
Ali
 
11:57 AM
Do one thing.
in the directory where your php file exists there will be a file named error_log
 
Ali
sure
ok
 
that file contains error that occurred on the scripts.. try viewing them.
 
Ali
got it, but there seems no error related to CURL
 
Oh if that is the case and you say curl is enabled on your server, then try contacting your customer care of your hosting provider and tell them the issue..

Oh wait
have you tried any other curl?
just try any other URL
and tell me if that works
 
Ali
yes i have been trying www.google.com
everything works good
also tried some other urls as well
tried this url with some dummy post parameters
and it worked fine
 
12:03 PM
Try this coding style for once
$url = 'http://domain.com/get-post.php';
$fields = array(
'lname' => urlencode($_POST['last_name']),
'fname' => urlencode($_POST['first_name']),
'title' => urlencode($_POST['title']),
'company' => urlencode($_POST['institution']),
'age' => urlencode($_POST['age']),
'email' => urlencode($_POST['email']),
'phone' => urlencode($_POST['phone'])
);

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
 
Ali
ok sure
 
Ali
this outputs 1
 
So is it working ?
is 1 the result you wanted ?
 
Ali
wait a sec
 
12:09 PM
or {"error":"unsupported_grant_type"} should have been the result?
 
Ali
i forgot to put my URL.
no it doesn't return me this json output
this is actually what i want
seems like my URL and hsoting server doesn't like each other
:)
i think i should talk to hosting support staff
 
Sorry bro can't help you more than this, looks like a weird issue.
Sure have a talk with them.
 
Ali
thank u so much bro
not a problem
you took time to rescue
worth appreciating (Y)
 

last day (14 days later) »