Topsy Tweets and Arabic (curl) - url

I am using the following URL to get all tweets that mention the farsi/arabic word "سلام" though the Topsy API:
http://otter.topsy.com/search.json?q=سلام&page=1&perpage=100&mintime=1244160000&maxtime=1244163600&apikey=FAF7F2D0D8A143978CB7762CE35FCF99
However, The results I get are as follows:
{"request":{"parameters":{"page":"1","q":"سلام","maxtime":"1244163600","perpage":"100","mintime":"1244160000"},"response_type":"json","resource":"search","url":"http://otter.topsy.com/search.json?maxtime=1244163600&mintime=1244160000&page=1&perpage=100&q=%D8%B3%D9%84%D8%A7%D9%85"},"response":{"window":"custom","page":1,"total":0,"perpage":100,"last_offset":0,"hidden":0,"list":[],"offset":0}}
The foreign word: "سلام" is read by the API as: %D8%B3%D9%84%D8%A7%D9%85 and thus no results are yielded. Any suggestions on what to do would be much appreciated!
Thanks :)

Both of them are equivalent. %D8%B3%D9%84%D8%A7%D9%85 is the HTML encoded version.

Related

How to specify a language using Insight API for Twitter from IBM Bluemix Platform

I'm starting to use Insight API for Twitter from IBM Bluemix.
It's hard to find supporting resource for using this. So far I am using CURL and specifically formed URL to query the API service, and the service returns results in JSON format.
Here's an example of the URL I used with CURL to search for some tweets with the API:
https://(my seucrity key)#cdeservice.mybluemix.net:443/api/v1/messages/search?q=$MSFT%28posted:2016-01-01T00:00:00Z,2016-09-01T00:00:00Z%29&size=20
This URL returns a JSON object with tweets with keyword #MSFT, and between the time frame of 2016-1-1 to 2016-9-1, only return 20 tweets.
I would like to add to that link by specifying a language for the tweet to search for, so far I come up empty. Can you please help me ?
I have tried adding the following to the URL and did not do anything:
lang=EN, lang="en"
lang:en, lang:EN
Thanks.
The syntax is lang:en and you need to make sure to include it as part of your query.
I created the following query based on the one you provided in your question:
https://username:password#cdeservice.mybluemix.net:443/api/v1/messages/search?q=(%24MSFT%20AND%20posted%3A2016-01-01T00%3A00%3A00Z%2C2016-09-01T00%3A00%3A00Z%20AND%20lang%3Aen)&size=20
The unencoded query is
($MSFT AND posted:2016-01-01T00:00:00Z,2016-09-01T00:00:00Z AND lang:en)
You can find documentation here.
But in this link you can find more details on the syntax, which is:
/api/v1/messages/search?q=QUERY&size=NUMBER&from=NUMBER

Wikipedia API request sometimes not returning results

I want to make a request to the Wikipedia API to see if a given name has a Wikipedia page.
For example, let's say I make an API request to get the page for Justin Bieber:
source = "https://en.wikipedia.org/w/api.php?action=query&titles=justin%20bieber&prop=revisions&rvprop=content&format=json"
data = open(source).read
json = JSON.parse(data)
Then I get back a JSON response with this info. But why is it not returning any result for some less well known name (even though they have wiki pages?) For example, this brent bolthouse page: https://en.wikipedia.org/wiki/Brent_Bolthouse. If I check the json, there's no indication that it's an actual page..
I basically just want to implement a simple check to see if there's a wiki page that matches the exact name.
Try capitalizing all parts of the name, e.g.:
"brent bolthouse".titleize
=> "Brent Bolthouse"
I suggest this because the titles of Wikipedia's pages on persons always have that format. While your URL with the lowercase name as the query doesn't work, the URL with the capitalized name does.
Ah, I found out MediaWiki is case sensitive for page titles.

json callback returns id_str as number

I have searched everywhere on the web, I have twitter implementation with monkeh coldfusion. The thing is callback returns id_str as number instead of string and I can't use it to reply/retweet/follow.
Any idea why comes like that and what I have to change ?
Thank you
There may not be anything wrong with your code, [id_str] is a number. If you are looking for the text in the tweet, it can be found at [text]. I hope this helps!
The issue was the we're using previous version of monkeh, once upgraded the id_str came as string.

How URL works? And what is the relation with GET and POST?

I have question, basic question I guess. But its important for me to learn more about web application.
I've ever seen a url with there are other words. for example:
http://api.openweathermap.org/data/2.5/weather?q=Setapak&mode=xml
there is q=setapak&mode=xml. what it means?
and what relationship with GET or POST?
when I try to create a simple page such which the code are:
<?lc
put $_GET['number'] into number
put number
?>
and I run the url on the browser: livecode/nana/url.lc?number=1
it shows nothing. So I get confuse. Can anyone explain to me?
Thank you..
Get will transfer you Parameter Using URL
all parameters will add to the URL ?number=1 this is one such example. it will carry number variable with value 1.
Post transfer parameters by attaching them to HTTP message body. Refer below link and you can get a good understanding about that.
http://www.w3schools.com/tags/ref_httpmethods.asp
You can't use single quotes in LC. use normal quotes around "number", and it should work.

Youtube API missing field

I have problem getting statistics information from youtube data api. I make a request to http://gdata.youtube.com/feeds/api/videos?q=video_id&alt=json, it works for some, but for some video id, the response does not contain 'entry', 'yt$statistics', 'gd$rating' for example:
zLcbznigfs missing 'entry', aVfN6XjACDY missing 'yt$statistics', fjhQ9Kf4iHk missing 'gd$rating'
After moving around, i found out the solution for this: use &alt=atom instead of using &alt=json, which means that we better read from Atom feed than JSON (and feedparser is an excellent module for doing this). I have checked this with several video id, it works fine.
Hope that help. Thanks.

Resources