Arabic With Twitter Tweet Service - web-services

I'm using the twitter tweet intent service and have run into a couple of issues in Arabic.
This is the call I am making:
https://twitter.com/intent/tweet?lang=ar&text=%D8%A3%D8%AF%D8%B9%D9%85%20%D9%82%D8%A8%D9%88%D9%84%20%D8%A7%D9%84%D8%AC%D9%85%D9%8A%D8%B9%D8%8C%20%D9%81%D9%8A%20%D9%83%D9%84%20%D8%A7%D9%84%D8%A3%D9%85%D8%A7%D9%83%D9%86.%20%23Rio2016%20%23VisaAcceptance&url=http%3A%2F%2Flocalhost%3A3000%2Fmena-ar%2F
The decoded parameters which are being pass are:
//text=أدعم قبول الجميع، في كل الأماكن. #Rio2016 #VisaAcceptance
//lang=ar
//url=http://localhost:3000/mena-ar/
It looks bad both when you are posting, the arrangement of the hashtag and URL are not working. And also when you view the post on twitter:
https://twitter.com/maxquesar/status/756573965498195968
Is this a twitter bug, or does anybody have experience fixing this type of issue?

To support Arabic with hashtags with the twitter intent service. You must pass the hashtags parameter.
This works correctly:
https://twitter.com/intent/tweet?hashtags=Rio2016%2CVisaAcceptance&lang=ar&text=.%D8%A3%D8%AF%D8%B9%D9%85%20%D9%82%D8%A8%D9%88%D9%84%20%D8%A7%D9%84%D8%AC%D9%85%D9%8A%D8%B9%20%D9%81%D9%8A%20%D9%83%D9%84%20%D8%A7%D9%84%D8%A3%D9%85%D8%A7%D9%83%D9%86&url=http%3A%2F%2Flocalhost%3A3000%2Fmena-ar%2F
The decoded params are:
//text=أدعم قبول الجميع، في كل الأماكن.
//lang=ar
//url=http://localhost:3000/mena-ar/
//hashtags=Rio2016,VisaAcceptance

Related

what is the difference between django html_message and message in send mail

When im trying to send a mail with django send mail only the html message is coming and not the normal message i want to know the difference between both.
Is there any best way to send mails through template or html files because i want a comming mailing system in my app.
Note:- the difference is of more important.
THIS IS WHAT I DID
msg_html = (' HELLLOOOOO')
msg_plain = 'Normalallalaa
send_mail("titleeeee", msg_plain,"sender#test",["reciever#tese",],html_message=msg_html)
My mail contained only Hello in bold
Where did my message go.
The problem is that some (old or specifically configured) email clients won't display HTML messages, therefore you need to make sure all your users can read your emails properly. If you decide to send just text, then users capable of getting HTML messages won't benefit from it.
This is the strategy I follow:
I use django.template.loader.render_to_string to render a template with a given context. The value this function returns is a string with a message in HTML.
html_text = render_to_string(template, context)
Then I create a plain text message based on the HTML message (for instance, by using a package named html2text):
plain_text = html2text(html_text)
And finally I send the email with django.core.mail.send_mail, passing html_text and plain_text as parameters.
Message is plain text, while html_message is a message formatted using HTML. If you set both, probably your email client is displaying the HTML version.

RequestVerificationToken is not idetifying/or getting assigned to variable by JMeter in a ASP MVC 5 Project

I am currently in a need of a Load test for a web-solution, which requires for a user authentication in Homepage (Welcome Page).
When I seek for the POST SignIn parameters which are passing along with the login credentials using FireBug in FireFox,
i found out that Password, TenantName, UserName, __RequestVerificationToken are the parameters which are passing along with their values for a successful login.
I needed to simulate this process using the JMETER.
Therefore i have made a HTTP REQUEST (Visit Login Page) to Navigate to the page using JMETER, which successfully work.
Within the HTTP REQUEST (Visit Login Page) I have added a Regular Expression Extractor, to Extract the token,
since it is necessary to pass the token along with the sign in.
Reference Name : REQUEST_VERIFICATION_TOKEN
Reg Expression : input name="__RequestVerificationToken" type="hidden" value="([A-Za-z0-9+=/-\ _]+?)"
Template : $1$
Match No. : 1
Default Value : (blank)
And I have added a separate HTTP Request (Login to Web) for signin along with the Parameters as follows;
Password : ${Password}
TenantName : ${TenantName}
Username : ${Username}
__RequestVerificationToken : ${REQUEST_VERIFICATION_TOKEN}
But When I Run it, under the View Results Tree,
the Response Data is generating as "The anti-forgery token could not be decrypted..."
When i check for the Request displays under View Result Tree,
it displays as
POST data:
Password=123456&TenantName=tenant&Username=admin&__RequestVerificationToken=%24%7BREQUEST_VERIFICATION_TOKEN%7D*
Where in the Request I realized the value for the RequestVerificationToken is not getting initialized.
I was searching for a solution through blogs for two days, where ultimately without a proper assistance I tend to post this question over here.
This is one reference link which is usefully for a extent, from which i used :
http://build-failed.blogspot.com/2012/07/load-testing-aspnet-mvc-part-3-jmeter.html?showComment=1417672985397#c6427302313332055578
Can someone assist me of Why the RequestVerificationToken is not extracting properly, or getting initialized to the variable?
( Ps : please be kind enough to assume that I'm a beginner in JMeter, to be honest, when you are providing your precious reply )
In Regular expression '-' has a meaning & it has to be escaped properly if it is expected in your __RequestVerificationToken value.
So, the correct regular expression would be
input name="__RequestVerificationToken" type="hidden" value="([A-Za-z0-9+=/\-\_]+?)"
I created a temp variable & verified above regular expression. It works fine. If it does not work for you, Please provide the HTTP response if possible.

Tweepy rate limit / pagination issue.

I've put together a small twitter tool to pull relevant tweets, for later analysis in a latent semantic analysis. Ironically, that bit (the more complicated bit) works fine - it's pulling the tweets that's the problem. I'm using the code below to set it up.
This technically works, but no as expected - the .items(200) parameter I thought would pull 200 tweets per request, but it's being blocked into 15 tweet chunks (so the 200 items 'costs' me 13 requests) - I understand that this is the original/default RPP variable (now 'count' in the Twitter docs), but I've tried that in the Cursor setting (rpp=100, which is the maximum from the twitter documentation), and it makes no difference.
Tweepy/Cursor docs
The other nearest similar question isn't quite the same issue
Grateful for any thoughts! I'm sure it's a minor tweak to the settings, but I've tried various settings on page and rpp, to no avail.
auth = tweepy.OAuthHandler(apikey, apisecret)
auth.set_access_token(access_token, access_token_secret_var)
from tools import read_user, read_tweet
from auth import basic
api = tweepy.API(auth)
current_results = []
from tweepy import Cursor
for tweet in Cursor(api.search,
q=search_string,
result_type="recent",
include_entities=True,
lang="en").items(200):
current_user, created = read_user(tweet.author)
current_tweet, created = read_tweet(tweet, current_user)
current_results.append(tweet)
print current_results
I worked it out in the end, with a little assistance from colleagues. Afaict, the rpp and items() calls are coming after the actual API call. The 'count' option from the Twitter documentation which was formerly RPP as mentioned above, and is still noted as rpp in Tweepy 2.3.0, seems to be at issue here.
What I ended up doing was modifying the Tweepy Code - in api.py, I added 'count' in to the search bind section (around L643 in my install, ymmv).
""" search """
search = bind_api(
path = '/search/tweets.json',
payload_type = 'search_results',
allowed_param = ['q', 'count', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'since', 'until', 'result_type', **'count**', 'include_entities', 'from', 'to', 'source']
)
This allowed me to tweak the code above to:
for tweet in Cursor(api.search,
q=search_string,
count=100,
result_type="recent",
include_entities=True,
lang="en").items(200):
Which results in two calls, not fifteen; I've double checked this with
print api.rate_limit_status()["resources"]
after each call, and it's only deprecating my remaining searches by 2 each time.

Artist info missing from Facebook Graph API /music.listens endpoint

I'm playing around w/ the /me/music.listens endpoint of Graph API and I have it working just fine. Except I can't seem to figure out how to get actual artist info to come back. I see the song and even the album (though that seems a little inconsistent too). But never any artist info.
Check the developer explorer here: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmusic.listens
No artist info. Is this just not returned? I can't see how to specify this in a fields param list. FB's documentation of the actions is spotty at best so I figured I'd try here.
Thanks!
I've figured out a work around. It doesn't look like Facebook actually returns artist info. So you have to use the Spotify Lookup Service (http://developer.spotify.com/technologies/web-api/lookup/).
To break it down a little further, you start by pulling the music.listens feed from FB and you'll get info that looks like:
(
[song] => Array
(
[id] => 381659191902248
[url] => http://open.spotify.com/track/**2Vv27Gc5k5GgGW9jgtj1CS**
[type] => music.song
[title] => Follow Through
)
)
From there, you need to grab the bolded track ID.
Lastly, fetch the song metadata with this call to Spotify: http://ws.spotify.com/lookup/1/.json?uri=spotify:track:2Vv27Gc5k5GgGW9jgtj1CS
You'll be returned the album name, artist info, etc.
If someone knows a better way, lemme know!
You can retrieve artists informations on graph API with the song id :
https://graph.facebook.com/song_id?fields=data{musician}
ex : https://graph.facebook.com/697975930266172?fields=data{musician}
Old question I know, but you can retrieve related information such as both the song title and artist title in the same request using Graph API's 'field expansion'.
For example - Last 10 songs
me?fields=music.listens.limit(10){data{song{title,id},musician{id,title}}}
To retrieve more information from either the song or musician entities just tweak the fields requested.
Note, this requires user_actions.music permission

Amazon Product Advertising API: Get Average Customer Rating

When using Amazon's web service to get any product's information, is there a direct way to get the Average Customer Rating (1-5 stars)? Here are the parameters I'm using:
Service=AWSECommerceService
Version=2011-08-01
Operation=ItemSearch
SearchIndex=Books
Title=A Game of Thrones
ResponseGroup=Large
I would expect it to have a customer rating of 4.5 and total reviews of 2177. But instead I get the following in the response.
<CustomerReviews><IFrameURL>http://www.amazon.com/reviews/iframe?...</IFrameURL></CustomerReviews>
Is there a way to get the overall customer rating, besides for reading the <IFrameURL/> value, making another HTTP request for that page of reviews, and then screen scraping the HTML? That approach is fragile since Amazon could easily change the reviews page structure which would bust my application.
You can scrape from here. Just replace the asin with what you need.
http://www.amazon.com/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=B000P0ZSHK
As far as i know, Amazon changed it's API so its not possible anymore to get the reviewrank information. If you check this Link the note sais:
As of November 8, 2010, only the iframe URL is returned in the request
content.
However, testing with the params you used to get the Iframe it seems that now even the Iframe dosn't work anymore. Thus, even in the latest API Reference in the chapter "Motivating Customers to Buy" the part "reviews" is compleatly missing.
However: Since i'm also very interested if its still possible somehow to get the reviewrank information - maybe even not using amazon API but a competitors API to get review rank informations - i'll set up a bounty if anybody can provide something helpful on that. Bounty will be set in this topic in two days.
You can grab the iframe review url and then use css to position it so only the star rating shows. It's not ideal since you're not getting raw data, but it's an easy way to add the rating to your page.
Sample of this in action - http://spamtech.co.uk/positioning-content-inside-an-iframe/
Here is a VBS script that would scrape the rating. Paste the code below to a text file, rename it to Test.vbs and double click to run on Windows.
sAsin = InputBox("What is your ASIN?", "Amazon Standard Identification Number (ASIN)", "B000P0ZSHK")
if sAsin <> "" Then
sHtml = SendData("http://www.amazon.com/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=" & sAsin)
sRating = ExtractHtml(sHtml, "<span class=""a-size-base a-color-secondary"">(.*?)<\/span>")
sReviews = ExtractHtml(sHtml, "<a class=""a-size-small a-link-emphasis"".*?>.*?See all(.*?)<\/a>")
MsgBox sRating & vbCrLf & sReviews
End If
Function ExtractHtml(sHtml,sPattern)
Set oRegExp = New RegExp
oRegExp.Pattern = sPattern
oRegExp.IgnoreCase = True
Set oMatch = oRegExp.Execute(sHtml)
If oMatch.Count = 1 Then
ExtractHtml = Trim(oMatch.Item(0).SubMatches(0))
End If
End Function
Function SendData(sUrl)
Dim oHttp 'As XMLHTTP30
Set oHttp = CreateObject("Msxml2.XMLHTTP")
oHttp.open "GET", sUrl, False
oHttp.send
SendData = Replace(oHttp.responseText,vbLf,"")
End Function
Amazon has completely removed support for accessing rating/review information from their API. The docs mention a Response Element in the form of customer rating, but that doesn't work either.
Google shopping using Viewpoints for some reviews and other sources
This is not possible from PAPI. You either need to scrape it by yourself, or you can use other free/cheaper third-party alternatives for that.
We use the amazon-price API from RapidAPI for this, it supports price/rating/review count fetching for up to 1000 products in a single request.