Twitterizer Follow Users with Stream - twitter

I'm currrently using the Twitterizer Framework to track many keywords (the limit is 400 from the Twitter API). Therefore, i try to follow some users (their timelines) but I get the Error "NotAcceptable".
Example Code A(this works):
StreamOptions options = new StreamOptions();
options.Track.Add("keyword 1");
options.Track.Add("keyword 2");
...
Example Code B(this works):
StreamOptions options = new StreamOptions();
options.Follow.Add("ID1");
options.Follow.Add("ID2");
...
Here I get the Error "NotAcceptable".
What I'm doing wrong?
Thanks!

this will be because of the type of stream you are starting. Right after the code you posted, you should have code to start your stream:
stream.StartPublicStream(...);
My guess is you actually have StartUserStream in error ...

Related

How do I find the Conversion Action ID for use in the Google Ads API?

I'm using the latest (v7) Google Ads API to upload offline conversions for Google Ads, using the Python Client Library. This is the standard code I'm using:
import os
from google.ads.googleads.client import GoogleAdsClient
client = GoogleAdsClient.load_from_env(version='v7')
def process_adwords_conversion(
conversion_date_time,
gclid,
conversion_action_id,
conversion_value
):
conversion_date_time = convert_datetime(conversion_date_time)
customer_id = os.environ['GOOGLE_ADS_LOGIN_CUSTOMER_ID']
click_conversion = client.get_type("ClickConversion")
conversion_action_service = client.get_service("ConversionActionService")
click_conversion.conversion_action = (
conversion_action_service.conversion_action_path(
customer_id, conversion_action_id
)
)
click_conversion.gclid = gclid
click_conversion.conversion_value = float(conversion_value)
click_conversion.conversion_date_time = conversion_date_time
click_conversion.currency_code = "USD"
conversion_upload_service = client.get_service("ConversionUploadService")
request = client.get_type("UploadClickConversionsRequest")
request.customer_id = customer_id
request.conversions = [click_conversion]
request.partial_failure = True
conversion_upload_response = (
conversion_upload_service.upload_click_conversions(
request=request,
)
)
uploaded_click_conversion = conversion_upload_response.results[0]
print(conversion_upload_response)
print(
f"Uploaded conversion that occurred at "
f'"{uploaded_click_conversion.conversion_date_time}" from '
f'Google Click ID "{uploaded_click_conversion.gclid}" '
f'to "{uploaded_click_conversion.conversion_action}"'
)
return False
I believe the code is fine, but I'm having problems locating the conversion_action_id value to use. In the Google Ads UI there's a screen listing the different Conversion Actions, with no sign of an ID anywhere. You can click on the name and get more details, but still no ID:
The conversion action detail screen in Google Ads UI
I've tried the following:
Using the ocid, ctId, euid, __u, uscid, __c, subid URL parameters from this detail page as the conversion_action_id. That always gives an error:
partial_failure_error {
code: 3
message: "This customer does not have an import conversion action that matches the conversion action provided., at conversions[0].conversion_action"
details {
type_url: "type.googleapis.com/google.ads.googleads.v7.errors.GoogleAdsFailure"
value: "\n\305\001\n\003\370\006\t\022dThis customer does not have an import conversion action that matches the conversion action provided.\0320*.customers/9603123598/conversionActions/6095821\"&\022\017\n\013conversions\030\000\022\023\n\021conversion_action"
}
}
Using the standard Google answer:
https://support.google.com/google-ads/thread/1449693/where-can-we-find-google-ads-conversion-ids?hl=en
Google suggests creating a new Conversion Action and obtaining the ID in the process. Unfortunately their instructions don't correspond to the current UI version, at least for me. The sequence I follow is:
Click the + icon on the Conversion Actions page
Select "Import" as the kind of conversion I want
Select "Other data sources or CRMs" then "Track conversions from clicks"
Click "Create and Continue"
I then get the screen:
Screen following Conversion Action creation
The recommended answer says:
The conversion action is now created and you are ready to set up the tag to add it to your website. You have three options and the recommended answer in this thread is discussing the Google Tag Manager option, which is the only option that uses the Conversion ID and Conversion Label. If you do not click on the Google Tag Manager option you will not be presented with the Conversion ID and Conversion Label.
Not so! What three options? The first "Learn more" link mentions the Google Tag Manager, but in the context of collecting the GCLID, which I already have. The "three options" mentioned in the official answer have gone. Clicking "done" simply takes me back to the Conversion Actions listing.
Using the REST API
I've tried authenticating and interrogating the endpoint:
https://googleads.googleapis.com/v7/customers/9603123598/conversionActions/
hoping that would give a list of conversion actions, but it doesn't. It just gives a 404.
Does anybody know a way of getting the Conversion Action ID, either from the UI or programmatically (via client library, REST or some other method)?
Thanks!
If you're using Python, you can list your conversions via next snippet:
ads: GoogleAdsServiceClient = client.get_service('GoogleAdsService')
pages = ads.search(query="SELECT conversion_action.id, conversion_action.name FROM conversion_action", customer_id='YOUR_MCC_ID')
for page in pages:
print(page.conversion_action)
You can also open conversion action in UI and locate &ctId=, that's the conversion action id.
I found this post with the solution how to get the Conversion Action ID:
(…) I found out that conversionActionId can be found also in Google
Ads panel. When you go to conversion action details, in URL there is
parameter "ctId=123456789" which represent conversion action id.
By the way, I tried something similar and it's still not working, but with this Conversion Action ID I get a different "Partial Failure" message, at least.
At least in Google Ads API (REST) v10,
it works if field conversionAction is set with value:
'customers/{customerId}/conversionActions/{ctId}'
customerId - without hyphens
ctId - conversion action id, as mentioned in above comments,
taken from GET parameters in Google Ads panel when specific conversion is opened.
Can also be found programmatically with API method.

Adwords API: Can't remove MyBusiness Location extension

I'd like to remove a location extension with the following code snippet:
FeedOperation feedOperation = new FeedOperation();
feedOperation.setOperand(FeedTemp);
feedOperation.setOperator(Operator.REMOVE);
It removes the location feed but leaves a message at the adwords page which says "invalid setting" (Ungültige Einstellung).See here
When I try to add a new location extension with the API, i get an error that a feed of this placeholder type already exists.
I already tried to remove the link between the location and a campaign with the following code without any success:
CampaignFeedOperation campaignFeedOperation = new CampaignFeedOperation();
campaignFeedOperation.setOperand(campaignFeed);
campaignFeedOperation.setOperator(Operator.REMOVE);
My only solution is to manually remove the location extension, which isn't doable for more than 100 customers.
Do you got any suggestion what i miss here?
I found my mistake.
Prior to removing the feed itself I need to remove the CustomerFeed:
CustomerFeedOperation customerFeedOperation = new CustomerFeedOperation();
customerFeedOperation.setOperand(customerFeed);
customerFeedOperation.setOperator(Operator.REMOVE);

how to Add titles and descriptions to videos on YouTube in other languages using api v3?

I had studied hardly the documentation on https://developers.google.com/youtube/v3/revision_history#november-19-2015 about how to Set localized titles and descriptions.
But when you try it, it seems impossible, even if you use the "app" of the api on https://developers.google.com/youtube/v3/docs/videos/update#prubalo you always get the same error with the parameter part. I set that parameter with the value "snippet", like you have to do. But it doesn't work, I tried with the rest of values or possible combinations and..it doesn't work.
Can someone give me an example of the code (i prefer python) or the request http ??
Please be sure you code o request http really works...even i found any mistakes on the examples on the documentation like 5 opening parenthesis and 4 closing parenthesis...
Following is an PHP code example. The concept is same, hope you can do it in the Phython.
Please make sure you set the default language of the video (snippet.defaultLanguage) before adding localisations.
// Call the API's videos.list method to retrieve the video resource.
// Part should be 'localizations' not 'snippet' because you are updating the localisation
$listResponse = $youtube->videos->listVideos('localizations', array('id' => 'YOUR_VIDEO_ID'));
// Since the request specified a video ID, the response only contains one video resource.
$video = $listResponse[0];
// Set the localisations array for the video localisation
// You can retrieve the language list from following API - https://developers.google.com/youtube/v3/docs/i18nLanguages/list
$video['localizations'] = array(
'ta' => array(
'title' => 'TITLE_IN_GIVEN_LANG',
'description' => 'DESC_IN_GIVEN_LANG'));
// Update the video resource by calling the videos.update() method.
$updateResponse = $youtube->videos->update('localizations', $video);
Update - Example of updating localisation of video using google developer console

Getting service metadata of SAPUI5 v2 ODataModel?

I try to get the service metadata of a sapui5 v2 odata model.
Code:
var oModel = new sap.ui.model.odata.v2.ODataModel(someServiceURL);
var oMetadata = oModel.getServiceMetadata();
This should work according to this page:
https://openui5beta.hana.ondemand.com/docs/guide/6c47b2b39db9404582994070ec3d57a2.html
Anyhow I got "undefined" for oMetadata.
If I change code to:
var oModel = new sap.ui.model.odata.v2.ODataModel({
loadMetadataAsync : false,
serviceUrl : someServiceURL
});
Still oMetadata === undefined
According to SDK documentation metadata should be loaded in sync:
Return the metadata object. Please note that when using the model with
bLoadMetadataAsync = true then this function might return undefined
because the metadata has not been loaded yet. In this case attach to
the metadataLoaded event to get notified when the metadata is
available and then call this function.
What is wrong with my code?
I am using (1.28.11):
<script src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js" ...
I started debugging the UI5 code and detected following line:
this.bLoadMetadataAsync = true;
I started debugging of SAPUI5 code and detected following line (seems to be called each time):
this.bLoadMetadataAsync = true;
Is it a bug? Or is something wrong with my code?
Solution:
The following worked for me in an actual application environment. I guess it not being fired in my fiddle was due to no actual data request being made:
var oModel = new sap.ui.model.odata.v2.ODataModel(<ServiceURL>);
oModel.attachMetadataLoaded(null, function(){
var oMetadata = oModel.getServiceMetadata();
console.log(oMetadata);
},null);
Lead up to the solution:
Ok so I started playing around with this a bit and found the following:
.getServiceMetadata() worked fine with sap.ui.model.odata.ODataModel.
with the sap.ui.model.odata.v2.ODataModel the request for the metadata was sent through the network but somehow .getServiceMetadata() returned undefined.
I tried to sap.ui.model.odata.v2.ODataModel.attachMetadataLoaded() but the event was never fired. (This only applied in the jsbin I used)
I will edit this with any further findings I make. If you have anything that should be included in my findings/testing just tell me.
Edit:
The bLoadMetadataAsync is a parameter you can set on the sap.ui.model.odata.ODataModel. The parameter is not in the API for sap.ui.model.odata.v2.ODataModel anymore. I assume that the async loading has been choosen as default.
Edit:
#user3783327 Reported a bug here: https://github.com/SAP/openui5/issues/564
As sirion already mentioned, the ODataModel has now an API named metadataLoaded which returns a promise accordingly. In the resolve function, we can definitely get the service metadata via getServiceMetadata().
myODataModel.metadataLoaded()
.then(() =>/* Do something with */myODataModel.getServiceMetadata());
Alternatively, we can also make use of ODataMetaModel which can be set on any ManagedObject (including View) and provides several useful accessors related to the service metadata. In order to get the meta model, we need to use the appropriate API from the ODataModel instead of instantiating the model directly:
myODataModel.getMetaModel().loaded()
.then(() =>/* Do something with */myODataModel.getMetaModel()/*...*/);
Documentation: Meta Model for OData V2

Difference between Msxml2.DOMDocument and Msxml2.XMLHTTP

What is the difference between:
Msxml2.DOMDocument
Msxml2.XMLHTTP
? And of course, the other question is which one will work best for my purpose as described below?
The context is this - I have code that makes many calls to retrieve web pages. I am looking for the most efficient object for this task. For example, something like this:
Dim oXmlHttp : Set oXmlHttp = CreateObject("MSXML2.XMLHTTP")
oXmlHttp.Open "GET", sUri, False
oXmlHttp.Send
If Err Then
getWebPage = "ERROR - could not get the source text of the webpage."
Exit Function
End If
sResponse = oXmlHttp.responseBody
This seems to work the same way if I create an object using:
Dim oXmlHttp : Set oXmlHttp = CreateObject("MSXML2.XMLHTTP")
Can anyone explain or point me to a reference that clearly outlines the differences (and intended usages) for each of those?
If you want to learn more about MSXML, these links may help:
http://msdn.microsoft.com/en-us/library/aa468547.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms766487(v=vs.85).aspx
In short, XMLHTTP is used to retrieve information, while DOMDocument is used to structure and parse it.
This page explains it better: http://msdn.microsoft.com/en-us/library/windows/desktop/ms760218(v=vs.85).aspx
DOMDocument "Represents the top node of the XML DOM tree." while XMLHTTP "Provides client-side protocol support for communication with HTTP servers."

Resources