Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/06/2011, 07:35
elcapitolio
 
Fecha de Ingreso: mayo-2011
Mensajes: 167
Antigüedad: 13 años
Puntos: 1
Respuesta: Ejecutar un script desde otro

Ya se cual es el problema, es la API de face como hago 2 peticiones simultaneas de POST no funciona, estuve leyendo la documentacion de FACEBOOK y lo que sugiere es que lo haga en batch... q yo supongo es procesamiento por lotes y q lo meta todo en arrays para hacer una sola peticion de post, la cosa es que ahora no se como hacerlo... navegando por ahi me encontre con este codigo pero no lo entiendo muy bien :S

Agradezco la ayuda

Código PHP:
Ver original
  1. $facebook = new Facebook(...your stuff here...);
  2. $access_token = ...get your access token however you want...;
  3.  
  4. $batch = array();
  5.  
  6. //build the body of the post first... these are, for the most
  7. //    part, the parameters which would normally be passed as
  8. //    params to the api call
  9. //any param normally passed as an array (such as properties
  10. //    and actions) MUST be json encoded
  11. //remember to urlencode all urls
  12. $body = array(
  13.   'id' => $page_or_user_id,  //I am using this with page id's to maintain
  14.                              //multiple pages at once
  15.   'message' => $message,
  16.   'link' => $link_url,
  17.   'actions' => json_encode(
  18.     array(array('name' => 'Action', 'link' => urlencode($action_url)))
  19.   ),
  20.   'properties' => json_encode(
  21.     array('Link' =>
  22.       array('text' => 'link text', 'href' => urlencode($other_link_url))
  23.     )
  24.   )
  25. );
  26.  
  27. //now build the query to be appended to the api url
  28. //I haven't come up with a better solution than this yet, but
  29. //    obviously it doesn't make sense to url encode all the
  30. //    characters only to decode them immediately after... Didn't
  31. //    want to have to write my own function yet :)
  32. $body = http_build_query($body);
  33. $body = urldecode($body);
  34.  
  35. //now build the request
  36. $request = array(
  37.   'method' => 'POST',
  38.   'relative_url' => 'feed',
  39.   'body' => $body
  40. );
  41.  
  42. //append this to the batch array
  43. $batch[] = $request;
  44.  
  45. //repeat this up to 19 times til you have all your requests in $batch then:
  46.  
  47. $params = array(
  48.   'access_token' => $access_token,  // if this is different for each
  49.                                     // request add this to $request instead
  50.   'batch' => json_encode($batch)
  51. );
  52.  
  53. $facebook->api('/', 'POST', $params);