Error OAuthException: (#200) when inviting to Event-Collection of common programming errors
I am getting the Error: Fatal error: Uncaught OAuthException: (#200)
when i try to invite people via an App to an event.
My Steps: 1. Getting long lived token with Permissions: create_event create_note publish_actions publish_stream rsvp_event user_events 2. Getting Userids who are friends and not already invited to the event. 3. Split into 50 Persons per Invite and send it.
Code for Inviting:
$friends = $facebook->api(array(
'method' => 'fql.query',
'query' => "SELECT uid,name FROM user WHERE uid IN
(SELECT uid1 FROM friend WHERE uid2=me()) AND NOT
(uid IN (SELECT uid FROM event_member where eid = '$eventid'))"));
foreach ($friends as $value)
{
if (!isset($allids))
{
$allids = $value['uid'];
}
else
{
$allids .= ',' . $value['uid'];
}
$count++;
$invitedusers++;
if ($count > 49)
{
//$splitinvite = $facebook->api($eventid . '/invited?users=' . $allids, 'POST');
unset($allids);
$count = 0;
}
}
$facebook->api($eventid . '/invited?users=' . $allids, 'POST');
I already seperated the Userids to make sure that they are setted correctly in the format Userid_1,Userid_2,Userid_3 I checked the token with the graph token debugger and all permissions are setted correctly. Anyone an idea?
-
One posibility is the following Code. But this works realy slow because it sends a query for each person. It takes up 30 Seconds for checking 37 people. Querying 50 people at once as shown above invites over 1000 people in 30 seconds.
I would appreacheate it if anyone can try to find a better way!!!
The best way would be filtering the FQL query (if is posible).Slow working Code:
foreach ($friends as $value) { try { $splitinvite = $facebook->api($eventid . '/invited?user=' . $value['uid'],'POST'); $count++; } catch (Exception $e) { // Users privacy setting blocked inviting him, has blocked you or has blocked you from inviting } }
Originally posted 2013-11-19 13:16:40.