Simple PHP API requests📚 Developer Resources
This is a simple function to make API requests. You can provide no post variables or any that are needed in the API call, this is only an example and you can provide the API variables in the URL if you want also. You can learn more about each API call that takes advantage of the API keys on the endpoint domain. You can see the API calls and more info on how to form request for content on the (https://endpoint.hey.cafe). ``` function heycafe_request($key,$call,$post=false){ :tab:$ch = curl_init("https://endpoint.hey.cafe/".$call."?auth=".$key.""); :tab:curl_setopt($ch, CURLOPT_HEADER, 0); :tab:curl_setopt($ch, CURLOPT_TIMEOUT, 30); :tab:curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); :tab:curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); :tab:curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)'); :tab:curl_setopt($ch, CURLOPT_FAILONERROR, true); :tab:curl_setopt($ch, CURLOPT_AUTOREFERER, true); :tab:curl_setopt($ch, CURLOPT_MAXREDIRS, 7); :tab:if ($post!=false){ :tab::tab:curl_setopt($ch, CURLOPT_POSTFIELDS, $post); :tab:} :tab:$response = curl_exec($ch); :tab:curl_close($ch); :tab:return $response; } $post = [ :tab:'content_raw' => 'Hello world' ]; $data=heycafe_request("YOURAPIKEY","post_conversation_conversation_create",$post); ```