I am trying to create an array from a MySQL query that I have.
This is to update facebook status' with the access tokens I have stored in my MySQL database. I am able to pull the access tokens without problem, but am having trouble creating an array that w开发者_JS百科ill list them as follows:array('token1', 'token2'..etc)
I have formatted the array to implode and give '' and a , but it still will not work.
any suggestions would be greatly appreciated.
$results = mysql_query("SELECT access_token
FROM demographic
ORDER BY access_token ASC");
while($access_token_array = mysql_fetch_assoc($results)) {
$list_access_token[] = $access_token_array['access_token'];
}
$comma_separated_quote = ("'" . implode("', '", $list_access_token) . "'");
$arr = array ($comma_separated_quote);
foreach ($arr as $tokens) {
$facebook->api('/me/feed','POST',array('access_token' => $str,'message' => 'test'));
}
Maybe I am reading this wrong but it looks like you want this...
<?php
$results = mysql_query("SELECT access_token FROM demographic ORDER BY access_token ASC");
while($access_token_array = mysql_fetch_assoc($results)) {
$facebook->api('/me/feed', 'POST', array('access_token' => $access_token_array['access_token'], 'message' => 'test'));
}
?>
Are you trying to post a message for every access_token?
Try replacing the $str with $tokens and it should work.
精彩评论