Notes of discussion :
1. Change get username to get Id
The way for the programming to recognise the latest tweet is using get Id but not username. If just get username, the programming would recognise the same username tweeted me and would not trigger the visual. Therefore, need to change to ID to get every it unique id for every tweet. In php, have to change from array 'screen_name' to $newArray[] = array('id'=>$t->id_str); and recent count to 1 but not 10 or 20. and in processing getString("id");
php :
processing :
2. Fetch every latest tweet only and not displaying all the array in the list once
After getting the ID and to make sure to get the latest tweet is to use the method currentId and previousId. The processing will recognise and store the currentId and when new currentId added, the old currentId will become previousId.
Here is part of the code to grab each latest tweet.
String currId = "";
String prevId = "";
void grab()
{
println("call grab()");
println("grab: pv"+prevId);
prevId = currId;
jsonArray = loadJSONArray("http://localhost/twitterapi/index.php");
JSONObject item = jsonArray.getJSONObject(0);
currId = item.getString("id");
println(currId);
}
Here the result in print in : The id number changes
No comments:
Post a Comment