As part of my university project, we are currently exploring the Twitter API. However, we are facing some challenges with the query functionality. I need to search for a complete string and enclose it in quotation marks (e.g., "Searching for this whole string"). The issue arises when the command I use to retrieve the array from Twitter ends up encoding the entire string, including the quotation marks. I'm hoping someone can help me resolve this dilemma. Below, I will also include my JavaScript code snippet.
JS CODE: Initially, I attempted using a JSON command which proved unsuccessful. Subsequently, I tried using AJAX but encountered the same problem. Whenever I include quotation marks in my query, the response fails to generate.
$( document ).ready(function()
{
console.log("ready");
// onClick1 function triggered upon clicking on anchor tag with id unique1
$('a#unique1').bind('click', onClick1);
});
function onClick1(elem)
{
var inputString = $("#SearchInput").val();
var EncodedString = encodeURI(inputString);
console.log('test' + inputString);
var endNode = 'search/tweets.json?q=hate%20' + EncodedString + '&result_type=mixed&count=200';
$.ajax({
type: "GET",
url: 'twitter/twitter-proxy.php?url='+encodeURIComponent(endNode),
data: " ",
success: function(twitterResponse){
var respStr = "start";
console.log(twitterResponse);
console.log(twitterResponse.statuses);
for(var i = 0; i < twitterResponse.statuses.length; i++)
{
$('.container .apiCall ol').append('<li>'+ twitterResponse.statuses[i].created_at + '</br>' + twitterResponse.statuses[i].text.toLowerCase() + '</li>');
respStr = respStr + twitterResponse.statuses[i].created_at + twitterResponse.statuses[i].text.toLowerCase();
}
}
});
}