EchoFool Posted April 7, 2010 Share Posted April 7, 2010 Hey, I want to know if theres a way to send links to an external site in the form of a POST without the user doing it from a form. A file host gave me their info for their API link checker and say: Feel free to use the link checking API that we uses. Simply POST to *url removed* and use the following name/value pairs: id$x=$downloadid Does any one understand what they are telling me to do .. im thinking CURL ? But i don't know where to start here =/ Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/ Share on other sites More sharing options...
teamatomic Posted April 7, 2010 Share Posted April 7, 2010 Curl or sockets.Heres a bit to get you started. http://www.alt-php-faq.org/local/55/#id55 HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038109 Share on other sites More sharing options...
EchoFool Posted April 7, 2010 Author Share Posted April 7, 2010 Hmm okay thats confusing i have alot of questions: <?php $URL="www.mysite.com/test.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://$URL"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");curl_exec ($ch); curl_close ($ch); ?> If i use CURL where do i get the return values =/ And if it returns a number of different values how do i know how to grab them :S This just seems to be doing an "include" rather than a way to return the values that im checking ? Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038113 Share on other sites More sharing options...
teamatomic Posted April 7, 2010 Share Posted April 7, 2010 You get it from curl the same way you get a page. All you are doing is submitting a request and waiting for the results, you are just passing a bit more than a simple request, thats all. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038119 Share on other sites More sharing options...
EchoFool Posted April 7, 2010 Author Share Posted April 7, 2010 Well i put this: <?php ForEach ($arr2 AS $Value){ $arr3 = str_split($var, 30); //cut off the url so it only has the ID in array[1] $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"removed from post"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "id$x=".$arr3[1].""); curl_exec ($ch); curl_close ($ch); Echo $Value.'<br>'; $var2 = $var2+ 1; } ?> Now the company told me this: The script will return name, site, size and status. Status is 0 for OK, 2 for expired and 3 for temporarily unavailable. But currently how do i get the return values from the above =/ because at the moment i don't have the returned values for me to use in my script ? Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038122 Share on other sites More sharing options...
teamatomic Posted April 7, 2010 Share Posted April 7, 2010 You have to ask curl to give you something. $result=curl_exec ($ch); var_dump()$result); also, where does $x come from? you dont show it in the code posted. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038127 Share on other sites More sharing options...
EchoFool Posted April 7, 2010 Author Share Posted April 7, 2010 I equally have no idea the info i was given by them said : Feel free to use the link checking API that we uses. Simply POST to *url removed* and use the following name/value pairs: id$x=$downloadid I am merely guessing the POST name is id$x and thus $x is not a variable but just a string =/ Currently i just get a return value of 1 , don't know if thats my issue or at their end so im awaiting a reply from them on more info that can aide in this problem. Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038132 Share on other sites More sharing options...
teamatomic Posted April 7, 2010 Share Posted April 7, 2010 No, $x is an integer, no one that writes an api would have id$x as it would cause a lot of problems in the processing. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/197819-send-post-to-external-site-without-forms/#findComment-1038137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.