Search code examples
phpapicurlmeetup

unable to rsvp on meetup through API


I am trying to update my rsvp status for an event, such as http://www.meetup.com/group/events/219126470/

$event_rsvp_url ="https://api.meetup.com/2/rsvp/?event_id=".$event_id."&key=".$this->meetup_api_key."&rsvp=no";
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $event_rsvp_url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
return $query;

this is all i am getting

string(0) ""

Solution

  • Turns out i was trying to get not post. This works for me.

    /**
        * Send a POST requst using cURL
        * @param string $url to request
        * @param array $post values to send
        * @return string
        */
        function curl_post($url, array $post = NULL){
            $cURL = curl_init();
            curl_setopt($cURL, CURLOPT_URL, $url);
            curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($cURL, CURLOPT_POST, 1);
            curl_setopt($cURL, CURLOPT_POSTFIELDS, $post);  
    
            if(!$result = curl_exec($cURL)) {
                trigger_error(curl_error($cURL));
            }
    
            curl_close($cURL);
            return $result;
        } 
    
    $post = array('event_id' => $event_id, 'key' => $api_key, 'rsvp' => 'yes', 'guests' => '0', 'member_id' => '9736856');
        $url = "https://api.meetup.com/2/rsvp/";   
        print_r($meetup->curl_post($url, $post));