How do I Auto Re-tweet Somebody or a Hashtag And Follow Them Using Tweetinvi - tweetinvi

I want to make a automatic re-tweet/follow bot so I can follow and re-tweet certain people and RT a specific hashtag (#Giveaways) I am using Tweetinvi but I dont understand how to do these things I've listed.

I am the developer of Tweetinvi.
You could simply do the following:
Auth.SetUserCredentials("CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");
var fs = Stream.CreateFilteredStream();
fs.AddTrack("#fnqifqun");
fs.MatchingTweetReceived += (sender, args) =>
{
var tweet = args.Tweet;
tweet.PublishRetweetAsync();
};
fs.StartStreamMatchingAllConditions();
Your bot is now complete!

Related

Getting to UM voicemail greetings for users in o365 using PowerShell or EWS

Hopefully a simple question - at one time I know when user's recorded their personal greetings for UM voicemail in o365 (regular greeting and/or extended absence greeting) these were stored in their Exchange inbox using a special item type (i.e. "IPM.Configuration.Um.CustomGreetings.External"). However setting up my test o365 setup, getting UM configured and all that, after recording my personal greeting and going through each item starting from the root of my inbox, (some 900+ items - lots of odd stuff in there) - I don't see anything like this any more. Lots of log, activity items, some messages but nothing about greetings. Extracting everything that could cast to an email type to a folder I went through each one - nothing promising.
anyone have any clues where the custom greetings for users UM (not auto attendant recordings - that's a different beast) has gone off to and how to get to it?
thanks much.
Got this working after a bit of flailing.
Ben Lye's post that Glen Scales provided in the comments above was what got me from A to B - Thanks Glen.
http://www.onesimplescript.com/2015/07/getting-um-voicemail-greetings-in.html
In related news Glen's very excellent PowerShell plug in for FAI exploration was also very helpful and can save you a bunch of time ramping up on the Folder Associated Information:
https://gsexdev.blogspot.com/2018/03/ews-fai-module-for-browsing-and.html
For those stumbling around with this in .NET using EWS, here's a quick stripped down blurb of code for fetching the standard and extended greeting recordings for a user - took me longer to slog through this than it should have, perhaps this can save someone a bit of time down the road:
note to run this against multiple mailboxes you'll need to have configured impersonation for your account you're authenticating with for EWS functions.
ExchangeService _service;
_service = new ExchangeService(ExchangeVersion.Exchange2016); // Exchange2013_SP1);
_service.Credentials = new WebCredentials("user#domain", "myPw");
_service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
//select the user you're fetching greetings for
_service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user#domain");
//get the root folder for the current account
var oParamList = new List<FolderId> {WellKnownFolderName.Root};
var oTemp = _service.BindToFolders(oParamList, PropertySet.FirstClassProperties);
var oRoot = oTemp.First().Folder;
var oView = new ItemView(50)
{
PropertySet = new PropertySet(BasePropertySet.FirstClassProperties),
Traversal = ItemTraversal.Associated
};
SearchFilter oGreetingFilter = new SearchFilter.ContainsSubstring(ItemSchema.ItemClass,
"IPM.Configuration.Um.CustomGreetings", ContainmentMode.Substring, ComparisonMode.IgnoreCase);
var oResults = _service.FindItems(oRoot.Id, oGreetingFilter, oView);
//fetch the binary for the greetings as values
var oPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
var oRoamingBinary = new ExtendedPropertyDefinition(31753, MapiPropertyType.Binary);
oPropSet.Add(oRoamingBinary);
_service.LoadPropertiesForItems(oResults, oPropSet);
var strFileName = "";
foreach (var oItem in oResults.Items)
{
if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.External",
StringComparison.InvariantCultureIgnoreCase))
strFileName = "jlindborg_Standard.wav";
if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.Oof",
StringComparison.InvariantCultureIgnoreCase))
strFileName = "jlindborg_Extended.wav";
File.WriteAllBytes("d:\\" + strFileName, (byte[]) oItem.ExtendedProperties.First().Value);
}
}

How to get active users of a specific page by Google analytics API?

I use rt:activeUsers metric to get active users on website for realtime data.
I want to get active users in real time for a specific page (path or url), not the whole website. Is there a way to implement it? I went through API Explorer but gain no success.
For anybody else looking for this below is an example of how I accomplished this in javascript.
I started with the sample at: https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/
That sample uses a extension to the embed api to get active users: active-users.js
I didn't know where to get that active-users.js file so I just used the developer tools in Chrome and grabbed it that way. Saved it locally and linked to it in my page. If anyone knows a official location to get that please comment below. Thx.
If you look at the source to that file, I modifed the pollActiveUsers function to add a filters parameter like so:
pollActiveUsers_: function () {
var t = this.get(),
i = 1e3 * (t.pollingInterval || 5);
if (isNaN(i) || i < 5e3)
throw new Error("Frequency must be 5 seconds or more.");
this.polling_ = !0,
gapi.client.analytics.data.realtime.get({
ids: t.ids,
metrics: "rt:activeUsers",
filters: t.filters
}).then(function (t) {
var e = t.result,
s = e.totalResults ? +e.rows[0][0] : 0,
n = this.activeUsers;
this.emit("success", {
activeUsers: this.activeUsers
}),
s != n && (this.activeUsers = s, this.onChange_(s - n)),
1 == this.polling_ && (this.timeout_ = setTimeout(this.pollActiveUsers_.bind(this), i))
}
.bind(this))
},
Now in my page javascript I can call it like so:
var activeUsers = new gapi.analytics.ext.ActiveUsers({
container: 'active-users-container',
pollingInterval: 5,
filters: "rt:pagePath==/somepath/somepage/",
ids: "ga:<yourviewid>"
});
Hope that helps somebody.
While the Real-time API is very limited it does allow you to use filters. Filters are a kind of where clause.
The real-time documentation is also very limited but you can look at the documentation for filters on the core reporting API it works the same
filters=ga:browser%3D~%5EFirefox
I think you should check out the dimension rt:pagePath its probably what you are looking for.

Google Apps - Share Contacts within Org

Within our Google Apps Org, I would like to setup a shared contact list that anyone inside our company can access and add/edit the contacts so we have all the same information. What is the best way to go about this?
I would create an application in App Engine that uses the Google APIs to edit the Shared Contacts list. That way you can restrict access to your domain users and also audit the activity that is occurring. There are third party tools out there that can edit the shared contact list but this is typically locked down to avoid situations where users delete contacts they should not be able to. Don't forget that the Shared Contacts list that appears in Gmail's type-ahead has a 24 hour delay.
Hey for anyone out there we used a Google Sheet, now anyone can update the sheet and you can either set an automated trigger to upload them on a schedule or manually push them into the Google Directory.
gsheet:
First we pull all the contacts from the directory then you can add/update/delete existing or new contacts.
Then push them to the Directory using the menu.
We made setup super simple so it auto grabs the user info and domain etc without the user having to do anything
var SHEET_NAME = 'google';
var ERROR_RECIPIENT_MAIL= Session.getActiveUser().getEmail();
var DOMAIN = ERROR_RECIPIENT_MAIL.replace(/.*#/, "");
Then we call the Domain Shared Contacts API to get all the data and put it into an array:
function getAllContacts(){
var contacts = ContactsApp.getContacts();
var lastRow = SpreadsheetApp.getActiveSpreadsheet().
getSheetByName(SHEET_NAME).getLastRow();
if (lastRow >2) SpreadsheetApp.getActiveSpreadsheet().
getSheetByName(SHEET_NAME).deleteRows(3, lastRow*1-2);
var contacts = ContactsApp.getContacts();
var params = {
method : "get",
contentType : "application/atom+xml",
headers : {"Authorization": "Bearer " +
ScriptApp.getOAuthToken(),"GData-Version": "3.0"},
muteHttpExceptions : true
};
var startIndex=1;
var data,respCode,resp;
resp = UrlFetchApp.fetch("//www.google.com/m8/feeds/contacts/"
+DOMAIN+"/full?alt=json&start-index="+startIndex, params);
respCode=resp.getResponseCode();
//SpreadsheetApp.getActiveSpreadsheet().
// getSheetByName(SHEET_NAME).getRange("A10").setValue(resp);
data = JSON.parse(resp.getContentText());
From there it's then put in the correct fields on the sheet for the user to update. Then the user selects the action from the drop down which calls the appropriate function when the script is run to update.
Example of delete function:
function deleteContact(contactID,rowNumber){
var params = {
method : "delete",
contentType : "application/json",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken(),"GData-Version": "3.0","If-Match":"*"}
};
var resp = UrlFetchApp.fetch(contactID, params);
var respCode=resp.getResponseCode();
if (respCode=='201' || respCode=='200') {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME).deleteRow(rowNumber*1);
}
else{
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME).getRange(rowNumber*1, 15, 1, 1).setValue('ERROR');
ERROR_COUNT=ERROR_COUNT.toString()+rowNumber;
}
}
It's pretty cool, and now we are working on bulk data entry as it seems to stall or stop after about 700 contacts in a single run. Also some of the contacts don't get synced and have an error which we'll work on shortly to get the user more info and even store the missed contact to be fixed and updated after. Anyway hope that helps and gives you some ideas.
Ours is located here for anyone interested.

Facebook Graph API - Get ID from Facebook Page URL

I have seen this question but what I want is different.
I want to get the Facebook ID not from a general URL (and therefore conditional if it has Like button or not). I want to get the Facebook ID given a Facebook page using the Graph API.
Notice that Facebook pages can have several formats, such as:
http://www.facebook.com/my_page_name
http://www.facebook.com/pages/my_page_name
http://www.facebook.com/my_page_ID
I know I could do some regex to get either the my_page name or my_page_ID, but I am wondering if any one know if GraphAPI is supporting what I want.
It seems to me that the easiest solution to what you describe is to just get the id/name from the url you have using lastIndexOf("/") (which most languages have an equivalent for) and then get "https://graph.facebook.com/" + id.
The data that this url returns has the id (i.e.: 6708787004) and the username (i.e.: southpark), so regardless of which identifier you use (what you extract from the url using lastIndexOf), you should get the same result.
Edit
This code:
identifier = url.substring(url.lastIndexOf("/"))
graphUrl = "https://graph.facebook.com/" + identifier
urlJsonData = getGraphData(graphUrl)
Should work the same (that is result with the same data) for both:
url = http://www.facebook.com/southpark
And
url = http://www.facebook.com/6708787004
(you'll obviously need to implement the getGraphData method).
Also, the 2nd url form in the question is not a valid url for pages, at least not from my tests, I get:
You may have clicked an expired link or mistyped the address. Some web
addresses are case sensitive.
The answer to the question is posted above but the method shown below works fine we do not have to perform the regex on the facebook page urls
I got the answer by this method
FB.api('/any_fb_page_url', function(response){
console.log(response);
});
any_fb_page_url can be any of the following types
https://www.facebook.com/my_page_name
https://www.facebook.com/pages/my_page_name
https://www.facebook.com/my_page_ID
This are also listed in question above
This code is tested on JS console available on Facebook Developers site tools
You can get the page id by using the below api
https://graph.facebook.com/v2.7/smhackapp?fields=id,name,fan_count,picture,is_verified&access_token=access_token&format=json
Reference image
This answer is updated and checked in 2019:
and it is very simple because you do not need to extract anything from the link. for examples:
https://www.facebook.com/pg/Vaireo-Shop-2138395226250622/about/
https://www.facebook.com/withminta
https://www.facebook.com/2138395226250622
https://graph.facebook.com/?id=link&access_token=xxxxxxxx
response:
{
"name": "Vaireo Shop",
"id": "2138395226250622"
}
full nodeJS answer:
async function getBusinessFromFBByPageURL(pageURL: string) {
const accessToken = process.env.fb_app_access_token;
const graphUrl = `https://graph.facebook.com/?id=${pageURL}? access_token=${accessToken}`;
const fbGraphResponse = await Axios.get(graphUrl);
<?php
function getFacebookId($url) {
$id = substr(strrchr($url,'/'),1);
$json = file_get_contents('http://graph.facebook.com/'.$id);
$json = json_decode($json);
return $json->id;
}
echo getFacebookId($_GET['url']);
?>
Thats a PHP example of how to get the ID.
As of Nov 26 2021 none of these solutions work.
Facebook has locked down the API so you need an App Review.
https://developers.facebook.com/docs/pages/overview/permissions-features#features
This answer takes into account that a URL can end with a trailing slash, something that Facebook event pages seem to have in their URLs now.
function getId(url) {
var path = new URL(url).pathname;
var parts = path.split('/');
parts = parts.filter(function(part) {
return part.length !== 0;
});
return parts[parts.length - 1];
}
You can Use Requests and re Modules in python
Code:
import requests,re
profile_url = "https://www.facebook.com/alanwalker97"
idre = re.complie('"entity_id":"([0-9]+)"')
con = requests.get(profile_url).content
id = idre.findall(con)
print("\n[*] ID: "+id[0])
Output:
[*] ID: 100001013078780
Perhaps you can look through the https://developers.facebook.com/docs/reference/api/#searching docs: search against a couple of types and if you find what you're looking for go from there.

Post on Friends' Wall(s) via Facebook Actionscript 3 SDK

I'm absolutely new to programming and just managed to learn the basics of ActionScript 3. Now, I would like to learn how to post on my Friends' Walls via the as3 SDK using the UI class (taken from a nice Tutorial):
This is how I post on my own Wall:
protected function newsFeed ():void
{
// define your caption text
var theCaption:String = "CaptionText";
// define the descrition text
var theDescription:String = "Text for game Achievement";
// We need to follow the FB docs to tell it what sort of input we are sending to FB
// We are trying to set the 'feed'
var methodInput:String = 'feed';
var thePicture:String = "mylink/picture.png";
var theLink:String = "mylink";
var theName:String = "Name of FB Status Setter";
// Create an object that we'll call 'data' and fill it with the actual data we're sending to Facebook
var data:Object = {
caption:theCaption,
description:theDescription,
picture:thePicture,
name:theName,
link:theLink
};
Facebook.ui(methodInput, data, onUICallback);
}
protected function onUICallback(result:Object):void
{
// do something
}
This works perfectly fine. I know that I have to integrate the parameter "to" somewhere. But I don't know where and how. Sorry I'm very very new to this. This is from Facebook Docs
Properties
from: The ID or username of the user posting the message. If this is unspecified, it defaults to the current user. If specified, it must be the ID of the user or of a page >that the user administers.
to: The ID or username of the profile that this story will be published to. If this >is unspecified, it defaults to the the value of from.
Hopefully someone can help me out.
Best Regards,
Amir
P.S.: Is there a way to post only one friend's wall and another way to post on several friends' walls?
I believe you want to use Facebook.api() rather than 'ui'. According to the documentation for the AS3 FB API, 'ui' just opens the share dialog. If you want to create a post on a friends wall, then you'll want to use 'api'.
I haven't tested this in Flash, but I think you can set the method as /PROFILE_ID/feed ... of course replacing "PROFILE_ID" with the FB uid of the friend. Then, include the arguments; message, picture, link, name, caption, description and source in your data object.
So your code would look something like:
var method:String = "/friend_id/feed";
var data:Object = {};
data.message = "Your message";
data.picture = "http://www.google.com/kittens.jpg";
data.link = "http://www.mysite.com/link";
data.caption = "Your caption";
data.description = "Your description";
data.source = "http://www.mysite.com/video.swf";//(optional) source is a video or Flash SWF
Facebook.api(method, yourCallback, data, "POST");
function yourCallback(result:Object, fail:Object):void {
if (result) {
trace(result)
} else if (fail) {
trace(fail);
}
}
If you have multiple friends, you could probably just put the uid's in an array and loop through the method above. The AS3 API has a batch request method that I haven't tried, but you can check out the Documentation.
Facebook has some pretty helpful tools that are somewhat hidden.
Checkout their Debugger and their Graph API Explorer
Hope that's helpful.