, need to turn twitter.com/TWITTERUSER/status/377991264722894848 into https://twitter.com/intent/favorite?tweet_id=377991264722894848 I essentially want to know how to set it up to replace everything but the tweet ID number at the end with this beginning https://twitter.com/intent/favorite?tweet_id=
Perhaps you are looking for the Regex operator, with parameters:
In = item.twitter_url
replace = .*/status/([0-9]+).*
with = https://twitter.com/intent/favorite?tweet_id=$1
Related
I have a string of email in a variable such as "Bill Warner (abc Ltd.)" <bill#abc.com>, "Paula Warner" <paula#abc.com>
I would like to create an array that extract each of the email and returns ["bill#abc.com","paula#abc.com"]
I find a way to make the extraction, using a custom function:
def string_between_markers marker1, marker2
self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
end
Only issue, is that this works only once.
What would be the right method to extract each of the email address please ?
I used the following and it works:
.scan(/\<(.*)\>/).flatten
I have localization in my app for French language which I have implemented like so...
I have a file called Localizable.strings(French) which contains all the French keywords given like so...
"Hello" = "Bonjour";
"Tree" = "Arbre";
"Sun" = "soleil";
And if I want to localize a particular label, I do it like so...
myLabel.text = "Hello".localized
Now say I get some keywords like these from an API :
"Moon" = "Lune”;
"car" = "auto”;
How can I update my Localizable.strings(French) file with these keywords programatically without having to go and manually enter the keywords I get from the API..?
I referred this link and also looked up other similar answers in SO..but couldn't get a solution yet...
My problem is i need a bit of code to reference a tracking number eg 1193849302, and insert it into a url http://www.example.com/track=[tracking number], so that the [tracking number] is replaced by 1193849302
then to have showing only the tracking number which is hyperlinked to said URL, i.e. 1193849302 (hyperlinked)
Either in html or javascript I think most of the site is CSS based though
Is this possible?
Thanks in advance
Edit maybe i should explain what i want a bit better
I have a customer area on a retail website , which returns the customers parcels tracking number when despatched.
What i'm after is a way to turn this tracking number into a working hyperlink which when clicked opens a new window into the couriers website automatically pushing the tracking number into the url and tracking the parcel for them.
Does this sound possible??
Most languages have a String.replace function.
For example, in Javascript, use replace() for this. Note that it takes a regex as an argument, so the [] need to be escaped:
var str = "http://www.example.com/track=[tracking number]";
str = str.replace("\[tracking number\]", "1193849302");
use String.replace method
The replace() method searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced.
var str="http://www.example.com/track=[tracking number]";
var n=str.replace("tracking number","1193849302");
You can find more informations at http://www.w3schools.com/jsref/jsref_replace.asp
Is there a way retrieving all the tweets from a list of profiles (3) which are tagged with certain #hashtag in a single call to the Twitter API using 1.1?
If not, obviously, I'd be retrieving a hundred tweets from each user, and filtering out those which do not have the #hashtag .. but it's not very efficient, right?
Thanks in advance
Note: I've updated the library so I suggest you grab the newly updated version before trying this - I've made it so you don't need to manually encode each individual character.
This page shows you how to use search, and has a number of operators down toward the bottom of the page. One of these is the OR operator:
Getting tweets for multiple users
OR - Either this or that
love OR hate - containing either "love" or "hate" (or both)
From - From this user
from:twitterapi sent from the user #twitterapi
So, armed with the above knowledge, I'm guessing your query would look like this:
Translated into a GET request:
?q=from:user1+OR+from:user2
Getting tweets for specific hashtags
So that's how you get tweets for multiple users. The next step you want is for certain hashtags.
#haiku - containing the hashtag "haiku"
That translated individually into the correct format becomes:
?#haiku (or %2C haiku, depending on the library / urlencoding you're using)
Combining the above
The standard AND operator looks like this:
twitter search - containing both "twitter" and "search". Default operator
For a get request:
?twitter+search
So let's combine all this!
?q=#hashtag1+#hashtag2+from:user1+OR+from:user2
And, because you're using my lib, here's the code for that:
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$requestMethod = 'GET';
$getfield = '?q=#hashtag1+OR+#hashtag2+from:username1+OR+from:username2';
$twitter = new TwitterAPIExchange($settings);
$json = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
var_dump(json_decode($json));
I am trying to search all tweets with a given hashtag (Using titanium appcelerator).
I have a working code to search all tweets from a given user (for example #prayforjapan).
Now I'm trying to get all the tweets from #prayforjapan. This isn't working..
I tried the following method (since i found it on here
Now to search for the names i use this url:
var xhr = Ti.Network.createHTTPClient();
xhr.timeout = 1000000;
xhr.open("GET","http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+screen_name);
For the Hashsearch i tried the following code (doesn't work tho)
var xhr = Ti.Network.createHTTPClient();
xhr.timeout = 1000000;
xhr.open("GET","http://search.twitter.com/search.json?q=prayforjapan");
Does anyone know what's wrong with this search? or which link it should be?
Thanks!
Well, I played with it for a little bit and came up with this link format.
http://search.twitter.com/search?q=%23prayforjapan
How does that work?
%23prayforjapan is same as #prayforjapan
Sorry, Twitter does not supply this, neither with Rest or Streaming APIs. They only provide partial results unless you pay for the "garden hose" or "firehose," both of which are very costly. Garden hose starts at about $6,000/month, currently.