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);

Recommended Answers

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

       
Jump to Post

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.

Jump to Post

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 …
Jump to Post

All 11 Replies

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
....
...
...
?>

hi
will it run when the page is load?

thnank you

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.

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

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.

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

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.

thank you very very much
it works great
many thanks

thank you very very much
it works great
many thanks

Mark as solved if ur problem is solved

how do i do that?

thank you

Click here to mark the thread as read....
For using the onload option is notworthy on the body event...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.