Reputation: 51
file_get_contents() [function.file-get-contents]: SSL: Connection reset by peer in
on
file_get_contents("https://api.facebook.com/method/events.invite?eid=" . $eid . "&uids=" . json_encode($uids) . "&access_token=" . $facebook->getAccessToken())
It invites users friends which they selected to the event, however
i'm getting the error at the top of this post. Tested with cURL
, same error.
TESTED
I went back and tested some things with cURL
$url = "https://api.facebook.com/method/events.invite?eid=157437064317827&uids=" . json_encode($uids) . "&access_token=" . $facebook->getAccessToken();
$url2 = urlencode($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch) or die(curl_error($ch));
curl_close($ch);`
Getting errors with that: Couldn't resolve host 'https%3A%2F%2Fapi.facebook.com...
Upvotes: 5
Views: 2541
Reputation: 17718
You should never URLencode a full URL. You should URLencode specific portions of a URL (i.e. the query parameter names and values), but the whole URL being URL-encoded will cause your code to fail, since the parts of the URL won't be properly separated.
Upvotes: 1
Reputation: 33
Have you tried using the Graph API, rather than the deprecated API?
You could instead call:
$event_id = "EVENT_ID";
$user_ids = "ID1,ID2,ID3"; // this can be populated however, but that's the syntax
$graph_url = "https://graph.facebook.com/{$event_id}/invited/{$user_ids}";
$graph_contents = file_get_contents($graph_url);
$data = json_decode($graph_contents);
Hope this helps. :)
Upvotes: 2