How to slow down posting using fb app?

Go To StackoverFlow.com

0

below is code of my app

        $response1 = $facebook->api('/294120253958442' . '/feed','POST',$WallPost); sleep(5);
        $response2 = $facebook->api('/134804409926272' . '/feed','POST',$WallPost); sleep(15);
        $response3 = $facebook->api('/202619002037' . '/feed','POST',$WallPost); sleep(8);
        $response4 = $facebook->api('/30410040944' . '/feed','POST',$WallPost); sleep(6);
        $response5 = $facebook->api('/103561223082520' . '/feed','POST',$WallPost); sleep(12);

i use this text with sleep timer but the problem is that some posts posted correctly but some posted immediately is there any perfect solution i have to make almost 123 api request and people will like and comment

So the question is that is there any way to let fb think that this is the normal request like i use sleep() but its not working correctly?

note: I posted in my delected groups which i have to authorize to post and i just share the message which i want to share and its not a spam for further info please discuss before down vote thanks

Update

below is my complete file code requested by my friend zerkms :)

        //making fb instance so that we can make api calls 
        require_once 'library/facebook.php';


            // Create our Application instance.
            $facebook = new Facebook(array(
              'appId' => '1498*53*179__47',
              'secret' => 'Shhh... Its Seceret ;)',
              'cookie' => true,
            )); 


        //Prepare Wall post

            //connecting to mysql server and database than get the data 
                $con1 = mysql_connect("localhost","user","pass;)");
                    if (!$con1)
                      {
                          die('Could not connect: ' . mysql_error());
                          }


                mysql_select_db('db:P');

                //get last post info
                $query = mysql_query("SELECT * FROM info:) LIMIT 1");
                $row = mysql_fetch_array($query);
                $last_post = $row["last_post"];


                //get current post data 
                $query1 = mysql_query("SELECT * FROM post_data;) WHERE ID=$last_post  LIMIT 1");
                $row1 = mysql_fetch_array($query1);


            //store table data in variable 
                $pmessage = $row1["message"];
                $plink = $row1["link"];
                $pname = $row1["name"];
                $pcaption = $row1["caption"];
                $pdescription = $row1["description"];
                $ppicture = $row1["picture"];
                $psource = $row1["source"];



            //long life access_token

                $long_life_token = "AAACITTZBnadsBAEKaetzal7w*pk0yBgeaRMZAit8iZAbhqyXVX*3IYCZB_changed_CtS3CrqBmLa9rPueABbZAmZClX1bwZDZD";

        //'picture' => $ppicture, 'source' => $psource include this latter

                    // compile the post for for user
                        $WallPost = array(
                            'access_token' => $long_life_token,
                            'message' => $pmessage,
                            'link' => $plink,
                            'name' => $pname,
                            'caption' => $pcaption,
                            'description' => $pdescription);  


        //making api call so that it can post on target wall
        $response = $facebook->api('/me' . '/feed','POST',$WallPost);

            $last_post_update = $last_post + 1;


    //update info table that post posted and next time we use next post for posting

        mysql_query("UPDATE info SET last_post=$last_post_update WHERE id='1'");

    //posting to groups wall with sleeping time support poster.xls
            $response1 = $facebook->api('/*941*0*395844*' . '/feed','POST',$WallPost); sleep(5);
            $response* = $facebook->api('/1348044099***7*' . '/feed','POST',$WallPost); sleep(15);
            $response3 = $facebook->api('/*0**1900*037' . '/feed','POST',$WallPost); sleep(8);
            $response4 = $facebook->api('/30410040944' . '/feed','POST',$WallPost); sleep(*);
            $response5 = $facebook->api('/1035*1**308*5*0' . '/feed','POST',$WallPost); sleep(1*);
            $response* = $facebook->api('/10*477739430335' . '/feed','POST',$WallPost); sleep(1*);
            $response7 = $facebook->api('/84**05480*' . '/feed','POST',$WallPost); sleep(1*);
            $response8 = $facebook->api('/187350*04**08**' . '/feed','POST',$WallPost); sleep(11);
            $response9 = $facebook->api('/4*39***49744' . '/feed','POST',$WallPost); sleep(10);
            $response10 = $facebook->api('/171***10**51' . '/feed','POST',$WallPost); sleep(13);
            $response11 = $facebook->api('/1*9197031*7*' . '/feed','POST',$WallPost); sleep(14);
            $response1* = $facebook->api('/10054*45**870*5' . '/feed','POST',$WallPost); sleep(*);
            $response13 = $facebook->api('/*45144714*93' . '/feed','POST',$WallPost); sleep(9);
            $response14 = $facebook->api('/17343**7*717815' . '/feed','POST',$WallPost); sleep(*);
            $response15 = $facebook->api('/111915**5557801' . '/feed','POST',$WallPost); sleep(9);
            $response1* = $facebook->api('/133*0138**55770' . '/feed','POST',$WallPost); sleep(7);
            $response17 = $facebook->api('/158797974189338' . '/feed','POST',$WallPost); sleep(10);
            $response18 = $facebook->api('/*33*3078**94*08' . '/feed','POST',$WallPost); sleep(1*);
            $response19 = $facebook->api('/17410*979300***' . '/feed','POST',$WallPost); sleep(1*);
            $response*0 = $facebook->api('/157*481*430*458' . '/feed','POST',$WallPost); sleep(9);
            $response*1 = $facebook->api('/1*3941*97*85181' . '/feed','POST',$WallPost); sleep(11);
            $response** = $facebook->api('/1**089951*37501' . '/feed','POST',$WallPost); sleep(14);
            $response*3 = $facebook->api('/315**3*451*59*4' . '/feed','POST',$WallPost); sleep(10);
            $response*4 = $facebook->api('/***37895044*1*3' . '/feed','POST',$WallPost); sleep(7);
            $response*5 = $facebook->api('/*3*054393471390' . '/feed','POST',$WallPost); sleep(*);
            $response** = $facebook->api('/*440*1515*14491' . '/feed','POST',$WallPost); sleep(1*);
            $response*7 = $facebook->api('/184*7409490*430' . '/feed','POST',$WallPost); sleep(9);
            $response*8 = $facebook->api('/1*8978959817*19' . '/feed','POST',$WallPost); sleep(7);
            $response*9 = $facebook->api('/154*101413***7*' . '/feed','POST',$WallPost); sleep(7);
            $response30 = $facebook->api('/191***8809093*1' . '/feed','POST',$WallPost); sleep(*);
            $response31 = $facebook->api('/137*33949*59387' . '/feed','POST',$WallPost); sleep(7);
            $response3* = $facebook->api('/114474*38**4551' . '/feed','POST',$WallPost); sleep(10);
            $response33 = $facebook->api('/133*715934049*1' . '/feed','POST',$WallPost); sleep(9);
            $response34 = $facebook->api('/18**559*5137*33' . '/feed','POST',$WallPost); sleep(9);
            $response35 = $facebook->api('/1879447979*4870' . '/feed','POST',$WallPost); sleep(7);
            $response3* = $facebook->api('/1*1**94*7*37*85' . '/feed','POST',$WallPost); sleep(9);
            $response37 = $facebook->api('/175**51*91144**' . '/feed','POST',$WallPost); sleep(11);
            $response38 = $facebook->api('/15900418749*799' . '/feed','POST',$WallPost); sleep(11);
            $response39 = $facebook->api('/14487*885*10753' . '/feed','POST',$WallPost); sleep(*);
            $response40 = $facebook->api('/***9**507048858' . '/feed','POST',$WallPost); sleep(11);
            $response41 = $facebook->api('/*3*15140013*073' . '/feed','POST',$WallPost); sleep(9);
            $response4* = $facebook->api('/*07474*4***9741' . '/feed','POST',$WallPost); sleep(13);
            $response43 = $facebook->api('/151079718*78488' . '/feed','POST',$WallPost); sleep(7);
            $response44 = $facebook->api('/117*81001*43907' . '/feed','POST',$WallPost); sleep(8);
            $response45 = $facebook->api('/13*50*91*8*7594' . '/feed','POST',$WallPost); sleep(7);
            $response4* = $facebook->api('/1781*9*7**3*845' . '/feed','POST',$WallPost); sleep(1*);
            $response47 = $facebook->api('/3*9089400705' . '/feed','POST',$WallPost); sleep(9);
            $response48 = $facebook->api('/183898734978809' . '/feed','POST',$WallPost); sleep(8);
            $response49 = $facebook->api('/133453830051738' . '/feed','POST',$WallPost); sleep(10);
            $response50 = $facebook->api('/19*5151003*9374' . '/feed','POST',$WallPost); sleep(*);
            $response51 = $facebook->api('/1750793**574*93' . '/feed','POST',$WallPost); sleep(7);
            $response5* = $facebook->api('/*57554**4*7*93*' . '/feed','POST',$WallPost); sleep(13);
            $response53 = $facebook->api('/***3458071*0538' . '/feed','POST',$WallPost); sleep(9);
            $response54 = $facebook->api('/13430*43000*404' . '/feed','POST',$WallPost); sleep(11);
            $response55 = $facebook->api('/*77199875*3*5**' . '/feed','POST',$WallPost); sleep(10);
            $response5* = $facebook->api('/*54157594*37337' . '/feed','POST',$WallPost); sleep(13);
            $response57 = $facebook->api('/*8449745159*533' . '/feed','POST',$WallPost); sleep(*);
            $response58 = $facebook->api('/31487*4*1878045' . '/feed','POST',$WallPost); sleep(13);
            $response59 = $facebook->api('/*4943*4117707*1' . '/feed','POST',$WallPost); sleep(11);
            $response*0 = $facebook->api('/**7*8*5799989*5' . '/feed','POST',$WallPost); sleep(9);
            $response*1 = $facebook->api('/18*530908489557' . '/feed','POST',$WallPost); sleep(10);
            $response** = $facebook->api('/*877553*458415*' . '/feed','POST',$WallPost); sleep(10);
            $response*3 = $facebook->api('/*4844*48185*9*4' . '/feed','POST',$WallPost); sleep(*);
            $response*4 = $facebook->api('/1*5504393489378' . '/feed','POST',$WallPost); sleep(1*);
            $response*5 = $facebook->api('/1*4**58035**757' . '/feed','POST',$WallPost); sleep(9);
            $response** = $facebook->api('/*5403158795****' . '/feed','POST',$WallPost); sleep(9);
            $response*7 = $facebook->api('/179015*454*7358' . '/feed','POST',$WallPost); sleep(1*);
            $response*8 = $facebook->api('/*4407333937' . '/feed','POST',$WallPost); sleep(11);
            $response*9 = $facebook->api('/*14810578534008' . '/feed','POST',$WallPost); sleep(*);
            $response70 = $facebook->api('/*3*148493075*99' . '/feed','POST',$WallPost); sleep(8);
            $response71 = $facebook->api('/11193144**4495*' . '/feed','POST',$WallPost); sleep(7);
            $response7* = $facebook->api('/*375**97*9*3871' . '/feed','POST',$WallPost); sleep(13);
            $response73 = $facebook->api('/185**997144*979' . '/feed','POST',$WallPost); sleep(*);
            $response74 = $facebook->api('/1009957133*09**' . '/feed','POST',$WallPost); sleep(9);
            $response75 = $facebook->api('/15*71780480*458' . '/feed','POST',$WallPost); sleep(15);
            $response7* = $facebook->api('/19*783437031189' . '/feed','POST',$WallPost); sleep(1*);
            $response77 = $facebook->api('/1**0985*0795384' . '/feed','POST',$WallPost); sleep(9);
            $response78 = $facebook->api('/17173853951707*' . '/feed','POST',$WallPost); sleep(5);
            $response79 = $facebook->api('/1*1300933893455' . '/feed','POST',$WallPost); sleep(8);
            $response80 = $facebook->api('/1110945*899***1' . '/feed','POST',$WallPost); sleep(5);
            $response81 = $facebook->api('/18019587*0*1**4' . '/feed','POST',$WallPost); sleep(10);
            $response8* = $facebook->api('/15*805038117037' . '/feed','POST',$WallPost); sleep(14);
            $response83 = $facebook->api('/1300774704*5043' . '/feed','POST',$WallPost); sleep(10);
            $response84 = $facebook->api('/1*753918398*981' . '/feed','POST',$WallPost); sleep(13);
            $response85 = $facebook->api('/114514**1938101' . '/feed','POST',$WallPost); sleep(14);
            $response8* = $facebook->api('/1*3744*9038*735' . '/feed','POST',$WallPost); sleep(14);
            $response87 = $facebook->api('/10*10*97*150035' . '/feed','POST',$WallPost); sleep(*);
            $response88 = $facebook->api('/190**98943**081' . '/feed','POST',$WallPost); sleep(14);
            $response89 = $facebook->api('/17*47151*7***44' . '/feed','POST',$WallPost); sleep(9);
            $response90 = $facebook->api('/***8744437*8715' . '/feed','POST',$WallPost); sleep(*);
            $response91 = $facebook->api('/*****74477455*3' . '/feed','POST',$WallPost); sleep(13);
            $response9* = $facebook->api('/194974453897*45' . '/feed','POST',$WallPost); sleep(1*);
            $response93 = $facebook->api('/1873*78579**744' . '/feed','POST',$WallPost); sleep(1*);
            $response94 = $facebook->api('/*7**3183*1*351*' . '/feed','POST',$WallPost); sleep(8);
            $response95 = $facebook->api('/**0808*579778*3' . '/feed','POST',$WallPost); sleep(10);
            $response9* = $facebook->api('/*093457*5759184' . '/feed','POST',$WallPost); sleep(5);
            $response97 = $facebook->api('/*49****71754051' . '/feed','POST',$WallPost); sleep(9);
            $response98 = $facebook->api('/190487**0971307' . '/feed','POST',$WallPost); sleep(11);
            $response99 = $facebook->api('/1445955*8938380' . '/feed','POST',$WallPost); sleep(8);
            $response100 = $facebook->api('/*03438579**9*81' . '/feed','POST',$WallPost); sleep(7);
            $response101 = $facebook->api('/1147779*8*091**' . '/feed','POST',$WallPost); sleep(*);
            $response10* = $facebook->api('/1*8*89**7*40*08' . '/feed','POST',$WallPost); sleep(10);
            $response103 = $facebook->api('/*9*88*835781' . '/feed','POST',$WallPost); sleep(7);
            $response104 = $facebook->api('/1870*49980*47**' . '/feed','POST',$WallPost); sleep(7);
            $response105 = $facebook->api('/*358741898*8*48' . '/feed','POST',$WallPost); sleep(1*);
            $response10* = $facebook->api('/10***9409443*31' . '/feed','POST',$WallPost); sleep(*);
            $response107 = $facebook->api('/34*5*104*03*917' . '/feed','POST',$WallPost); sleep(10);
            $response108 = $facebook->api('/*45847838808173' . '/feed','POST',$WallPost); sleep(7);
            $response109 = $facebook->api('/184*7780157*777' . '/feed','POST',$WallPost); sleep(8);
            $response110 = $facebook->api('/1*83030*3*17*53' . '/feed','POST',$WallPost); sleep(9);
            $response111 = $facebook->api('/*58**851758958*' . '/feed','POST',$WallPost); sleep(8);
            $response11* = $facebook->api('/3197*341805**18' . '/feed','POST',$WallPost); sleep(10);
            $response113 = $facebook->api('/384*10481*0789*' . '/feed','POST',$WallPost); sleep(11);
            $response114 = $facebook->api('/180*4030*050*81' . '/feed','POST',$WallPost); sleep(11);
            $response115 = $facebook->api('/31308*5754048*8' . '/feed','POST',$WallPost); sleep(*);
            $response11* = $facebook->api('/311589115534*57' . '/feed','POST',$WallPost); sleep(8);
            $response117 = $facebook->api('/*3313*5434*00*3' . '/feed','POST',$WallPost); sleep(1*);
            $response118 = $facebook->api('/17*455045804750' . '/feed','POST',$WallPost); sleep(14);
            $response119 = $facebook->api('/*5**9457441*873' . '/feed','POST',$WallPost); sleep(1*);
            $response1*0 = $facebook->api('/15917*340789449' . '/feed','POST',$WallPost); sleep(11);
            $response1*1 = $facebook->api('/*37933149591088' . '/feed','POST',$WallPost); sleep(1*);
            $response1** = $facebook->api('/*15*93915**17*8' . '/feed','POST',$WallPost); sleep(14);
            $response1*3 = $facebook->api('/317348881**8*35' . '/feed','POST',$WallPost); sleep(13);
            $response1*4 = $facebook->api('/*77331**89**49*' . '/feed','POST',$WallPost); sleep(11);
            $response1*5 = $facebook->api('/15*3939948*9*94' . '/feed','POST',$WallPost); sleep(7);

?>
2012-04-03 20:29
by Abdullah Adam
Create some queue and run the worker periodicall - zerkms 2012-04-03 20:38
i didnt get your poin - Abdullah Adam 2012-04-03 20:39
i make file contain almost 123 api requests but the problem is that the sleep timer not work perfectly as its need to wor - Abdullah Adam 2012-04-03 20:40
why do you think it is sleep issue? sleep() function works perfectly. How big delays do you need - zerkms 2012-04-03 20:42
actually i checked first i try echo time than sleep() than echo time its work perfectly but when i try the above code its some times work perfectly and sometimes not i verify this with my friend who is in the same groups he get some notifications continuously and some after some tim - Abdullah Adam 2012-04-03 20:46
so, if sleep works perfectly - what the question is about then - zerkms 2012-04-03 21:00
no actually sleep works some times perfectly and sometimes i try to find any alternate or something which solve this sleep issu - Abdullah Adam 2012-04-03 21:03
it always works perfectly. The issue is not related to sleep at all. Could you please explain better with your real code (with sleeps), with your expectations and actual results? 35 minutes passed and still no details in the questio - zerkms 2012-04-03 21:05
@zerkms my dear friend check i update my complete file code and done some necessary changes in this if you find something in this code which not need to be exposed please let me known so that secret will be secret : - Abdullah Adam 2012-04-03 21:20
for such small sleep delays it is expected, because facebook doesn't guarantee anything to appear immediately on the pages, due to their cach - zerkms 2012-04-03 21:23
@zerkms can you please more clear your last commen - Abdullah Adam 2012-04-03 21:26
what you see as a result of execution of your script is expected facebook behaviour, because FB doesn't guarantee the feed to appear immediately after your API cal - zerkms 2012-04-03 21:27
let us continue this discussion in chatAbdullah Adam 2012-04-03 21:29


0

Try using functions instead: Not tested

function r1(){
    $response1 = $facebook->api('/294120253958442'.'/feed','POST',$WallPost);
}
function r2(){
    $response2 = $facebook->api('/134804409926272'.'/feed','POST',$WallPost);
}
function r3(){
    $response3 = $facebook->api('/202619002037'.'/feed','POST',$WallPost); 
}
function r4(){
    $response4 = $facebook->api('/30410040944'.'/feed','POST',$WallPost); 
}
function r5(){
    $response5 = $facebook->api('/103561223082520'.'/feed','POST',$WallPost);
}
r1();sleep(5);
echo date('h:i:s') . "\n";  // time stamps should echo 5 seconds apart.
r2();sleep(5);
echo date('h:i:s') . "\n";
r3();sleep(5);
echo date('h:i:s') . "\n";
r4();sleep(5);
echo date('h:i:s') . "\n";
r5();sleep(5);
echo date('h:i:s') . "\n";

Alternatively if sleep is returning null after sleep has occurred "windows server" you can set up a timer to fire the functions. Idle time is spent looping, not the best way to go.

function r1(){
    $response1 = $facebook->api('/294120253958442'.'/feed','POST',$WallPost);
}
function r2(){
    $response2 = $facebook->api('/134804409926272'.'/feed','POST',$WallPost);
}
function r3(){
    $response3 = $facebook->api('/202619002037'.'/feed','POST',$WallPost);
}
function r4(){
    $response4 = $facebook->api('/30410040944'.'/feed','POST',$WallPost); 
}
function r5(){
    $response5 = $facebook->api('/103561223082520'.'/feed','POST',$WallPost);
}
$i=1;
function timer(){
    $now = time();
    while ($now + 5 > time()) {
        // do nothing
    }
    if($i<5){
        $i++;r'.$i.'(); echo 'posted'.date('h:i:s') . "\n"; timer();
    }else{
        $i=1; echo 'starting over'; timer();
    }
}
2012-04-03 20:44
by Shawn E Carter
why you suggests function - Abdullah Adam 2012-04-03 20:49
Why do you think it would change anything? - zerkms 2012-04-03 21:00
i suggest this because php sleep can be interupted by signals and will always continue loading as sleep is in que.

wraping your request will prevent it from executing while the sleep's are qued.

MORE HELP HERE http://www.php.net/manual/en/function.sleep.ph - Shawn E Carter 2012-04-03 21:02

@Shawn E Carter: "wraping your request will prevent it from executing while the sleep's are qued" --- nope, you're wron - zerkms 2012-04-03 21:06
i just tested, works fine. :-) give it try - Shawn E Carter 2012-04-03 21:07
its shows this error

"Fatal error: Call to a member function api() on a non-object in mysite/script1c.php on line 78 - Abdullah Adam 2012-04-03 21:08

@Shawn E Carter: it works, but it wouldn't change anything in comparison to the same calls separated by sleeps. The wrapping with function adds NOTHING specia - zerkms 2012-04-03 21:09
@Abdullah Adam: of course - that's because $facebook is not defined within functions. But anyway - this solution is incorrect, just because it changes nothin - zerkms 2012-04-03 21:10
php will see the api request as just string, thus running it as sleep is in que, wrapping in a function, the request loads as a function and is executed only when called. How is this not logical - Shawn E Carter 2012-04-03 21:10
@Shawn E Carter: it's not logical, because what you say is just a nonsense. There is no difference how php calls the code. No difference at all. There is no any "queue - zerkms 2012-04-03 21:12
oh please no down vote at least care the persons effort and please remove down vote thank - Abdullah Adam 2012-04-03 21:22
@abdullah seeing your code i would create an array of your ids, then loop them calling a funtion like postid(groupid);sleep(7); where function itself includes the post request - Shawn E Carter 2012-04-03 21:43
thank you so much voted up :) i got the solution from @zerkms after a long discussio - Abdullah Adam 2012-04-04 10:32