0

hi, i am not a coder and trying to make this work

var body = 'Reading Connect JS documentation'; 
FB.api('/me/feed', 'post', { message: body }, function(response) { 
if (!response || response.error) { 
alert('Error occured'); 
} else { 
alert('Post ID: ' + response.id); 
} 
});

to make it work above code
I added this to make it work and it did

<body onload = "updating()" >
<script type="text/javascript" language="JavaScript">
function updating(){

I added the code here

                 }
</script>

so what would i do or add tho make the below code work when the page loads?
Thank you

$args = array( 
'message' => 'Hello from my App!', 
'link' => 'http://www.mysite.com/', 
'caption' => 'Visit Ma.....I.com For Facebook API Tutorials!'
); 
$post_id = $facebook->api("/me/feed", "post", $args);

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by tomato.pgn
0
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
})

This is javascript code. So you called that funnction in body onload.

But

$args = array(
    'message' => 'Hello from my App!',
    'link' => 'http://www.mysite.com/',
    'caption' => 'Visit Ma.....I.com For Facebook API Tutorials!'
    );
    $post_id = $facebook->api("/me/feed", "post", $args);

this is php code. so you can wriye this code from first line of your page within
<?php
....
...
...
?>

0

hi
will it run when the page is load?

thnank you

The codes should be executed if you place it in top of the page.

0

i will try it but i am trying to understand
don't i need something like this, so it will automaticly do the posting when users get to this page?

<body onload = "updating()" >
<script type="text/javascript" language="JavaScript">
function updating()
{ 
CODE
           
      }

</script><body onload = "updating()" >
<script type="text/javascript" language="JavaScript">
function updating(){


                 }
</script>

Thank you very much

Edited by serdas: n/a

0

i will try it but i am trying to understand
don't i need something like this, so it will automaticly do the posting when users get to this page?

<body onload = "updating()" >
<script type="text/javascript" language="JavaScript">
function updating()
{ 
CODE
           
      }

</script><body onload = "updating()" >
<script type="text/javascript" language="JavaScript">
function updating(){


                 }
</script>

Thank you very much

No need of any javascript to run php script on body load... Just write the php code on top of the page.

Edited by karthik_ppts: n/a

0

ok i will try that
i was not really asking for javascript but
i was trying to find out how to run the code with the page load similar way how the javascript does like onload finction
doesn't php needs some kind of triger for the fnction?
either onclick or onload?

Thank you for your help

0

ok i will try that
i was not really asking for javascript but
i was trying to find out how to run the code with the page load similar way how the javascript does like onload finction
doesn't php needs some kind of triger for the fnction?
either onclick or onload?

Thank you for your help

for onloading, no need to trigger for the function. Just place the code on the top of the page.

for onclicking, You need to use either get or post method in your form tag.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.