json - PHP cURL code fails online but not on localhost. Please help! -


I can not understand that this code works locally on my PC (localhost), but not online on public server is? Could this be a PHP version problem? Thanks for all the help! 'Test_value' = & gt; 'Test varde2', 'string_extra',

$ post_data = array ('item_type_id' => '8', 'string_key' => Test Nuke 2 ',' string_value '= & Gt; = & gt; Test Extra', 'Numeric_Actra' => 'Test Numeric Extra', 'Iopecic' => is true, 'is_public_for_contacts' = & gt; true); $ Post_data = json_encode (array ('item' = & gt; $ post_data), JSON_FORCE_OBJECT); $ C = curl_init ('http://example.com/items.json'); Curl_setopt ($ c, CURLOPT_VERBOSE, 1); Curl_setopt ($ c, CURLOPT_COOKIE, 'fb_cookie ='. $ Fb_code); Curl_setopt ($ c, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ c, CURLOPT_POSTFIELDS, $ post_data); Curl_exec ($ c); Curl_close ($ c);

curl_exec goes wrong if any request Fails from You can then get error codes and messages with curl_error () and curl_errno () :

  (curl_exec ($ c) ) = == FALSE) {dead ("curl fail:" .cll_uper ($ c)); }  

Never assume that curl call will be successful. Always check the returned value in case of some return, even if the curl is set up properly, then a network could mess up the connection, the remote server may down, the firewall's bad day Maybe, etc ...


Comments