Facebook graph api 2.9 get total count of friends only - c#

I can get JSON with all fields related to user_friends scope. However, from version 2.0 API returns mostly empty data[](if non of user's friend uses this app). Currently what I get is:
"friends": {
"data": [],
"summary": {
"total_count": 142
}
}
I want to extract only summary with total count of user's friends. So what I want to get is
"friends": {
"summary": {
"total_count": 142
}
}
Is this even possible?
I didn't find anything helpful about this in documentation, so any help is appreciated.

Related

Microsoft Graph API - not able to use orderby or filter on createdDateTime for Sites

I want to query Sites using Microsoft Graph API that were created after a certain time. So I created the following filter query:
createdDateTime ge 2023-01-01T00:00:00Z
I also tried:
createdDateTime ge `2023-01-01T00:00:00Z`
Both generated an invalid request error with no details.
I then tried just doing an orderby createdDateTime. This did "work" but it sorted each page, not the whole dataset. So page 2 had items that should have been in page 1 and so on.
Microsoft Graph API seems really crappy. Does anybody know how to achieve this? Any help would be greatly appreciated.
I've never found a way how to use filter on /sites endpoint.
I'm using /search/query endpoint for searching SharePoint sites based on some criterion.
You should be able to specify filter by Created and properties for sorting.
POST https://graph.microsoft.com/v1.0/search/query
{
"requests": [
{
"entityTypes": [
"site"
],
"query": {
"queryString": "Created > 2022-01-01 AND Created < 2022-12-31"
},
"from": 0,
"size": 25,
"sortProperties": [
{
"name": "Created",
"isDescending": "false"
}
]
}
]
}

Google Youtube API provides wrong data

I have a trouble with YouTube API. I have an experience in many API services and first time I encountered such strange work of this API.
Problem description:
First, I want to get subscribers of my channel. I'm developing this tool for my friend, but I take my own channel for testing purposes. So, doesn't matter how (through Web Interface of my C# tool), but I always get wrong data about my subscribers.
This is my json response:
...
"pageInfo": {
"totalResults": 17,
"resultsPerPage": 5
}, ...
Actual count of subscribers is 17. It is ok. But next, I have a list with subscribers description:
"items": [
{
"kind": "youtube#subscription",
"etag": "...",
"id": "...",
"subscriberSnippet": {
"title": "chris chandler",
"description": "",
"channelId": "UCbl-PjR7SwAQkGi2nUlZbMg",
...
}
},
And count of this blocks is 8.
I tried to set maxResults to 50 for getting all results in one page. But I always have 8 subscribers. I don't know why.
I tried tool with my friend's account. His actual count of subscribers is 385. But API shows only 301. Also I tried to get list of my subscriptions. Actual it is 107, but I get only about 80.
I've tested it with Web interface here:
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.list?part=subscriberSnippet&maxResults=5&mySubscribers=true
P.S. You can think, that some of YouTube data doesn't update momentarily. But I have constant amount of subscribers on my test channel about 3 years (It is about channel with 17 subscribers).

PayPal Rest API - Update Billing Plan Return URL

I have been using the PayPal Rest API and have successfully created and activated a BillingPlan but I'm having trouble updating said plan's return_url. I think it's something to do with the JSON path I'm using although I'm not sure why!?
Anyway, I am calling the update plan method: https://developer.paypal.com/docs/api/#update-a-plan
A BillingPlan follows the format:
{
"id": "P-94458432VR012762KRWBZEUA",
"state": "ACTIVE",
"name": "T-Shirt of the Month Club Plan",
"description": "Template creation.",
"type": "FIXED",
...
"merchant_preferences": {
"setup_fee": {
"currency": "USD",
"value": "1"
},
"max_fail_attempts": "0",
"return_url": "http://example.com",
"cancel_url": "http://example.com",
"auto_bill_amount": "YES",
"initial_fail_amount_action": "CONTINUE"
},
...
}
I'm using the C# SDK but my request JSON should look very much like:
{
"path": "merchant_preferences",
"value": {
"return_url": "http://example.com/payment/return"
},
"op": "replace"
}
I keep getting responses along the line's of:
{"name":"BUSINESS_VALIDATION_ERROR","details":[{"field":"validation_error","issue":"Invalid
Path provided."}],"message":"Validation
Error.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#BUSINESS_VALIDATION_ERROR","debug_id":"2ae68f9f0aa72"}
To sum up - I want to change the billing plan return_url from http://example.com to http://example.com/payment/return.
I've changed the path to various things to no avail. Can anyone help??
You cannot update the plan, once it is set to active. The reason for that restriction is that because there could be possible agreements based on that plan, modifying it would affect the already agreed billing agreements.
However, I agree with your problem statement, that changing the Return URL should not be an issue as this is not a part of agreement, but more of a configuration change. It would be nice to somehow allow updating similar settings in Plan, even after active. I will let the API team know about that.
however, in the mean time, there is no way you would be able to do that. Alternatively, you could possibly create a new plan, and use that instead. Not the answer you are looking for, but a probable solution.

Getting innacurate google search results from google APIs

What do I have?
Google Account.
Simple API Key access.
I have created a Custom Search Engine, I've set Search the entire web but emphasize included sites in it, and I have removed all the links from Sites to search section (so that it searched the entire web, and it's not restricted to a certain website).
From the Custom Search Engine I got CX (search engine ID).
If I try this command:
https://www.googleapis.com/customsearch/v1?key=[MY_API_KEY]&cx=017576662512468239146:omuauf_lfve&q=intitle:%22crazy+stink%22
(the CX is provided by google as an example here: https://developers.google.com/custom-search/json-api/v1/using_rest, but I get the same results if I set my own CX).
Results:
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
},
"queries": {
"request": [
{
"title": "Google Custom Search - intitle:\"crazy stink\"",
"totalResults": "0",
"searchTerms": "intitle:\"crazy stink\"",
"count": 10,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "017576662512468239146:omuauf_lfve"
}
]
},
"searchInformation": {
"searchTime": 0.35068,
"formattedSearchTime": "0.35",
"totalResults": "0",
"formattedTotalResults": "0"
}
}
If you test this out, you can see that this will give you 0 results, however if you perform a Google search for the same query, you'll get approx. 35 results: https://www.google.com/search?q=intitle%3A%22crazy+stink%22
This is the main reason why I'm asking for assistance. In my project I need all of these results, if normal Google search gives 35 results, I need to get these 35 results as well.
I need this for my C# project, however I don't really care in which format do I get the results (JSON, XML, etc...)
I plan on enabling billing feature, and exceeding the "Free" limitations of 100 queries/day I currently have. However before I do that I need to have fully functional facility (which I don't at the moment).
An additional note:
Even with the free AJAX Api: http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=1&rsz=large&q=intitle:%22crazy+stink%22 I get 0 results (you can test this one out without the API key).
Results:
{"responseData": {"results":[],"cursor":{"moreResultsUrl":"http://www.google.com/search?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d1\u0026hl\u003den\u0026q\u003dintitle:%22crazy+stink%22","searchResultTime":"0.10"}}, "responseDetails": null, "responseStatus": 200}
Any ideas, suggestions are more than welcome.
With this api https://developers.google.com/custom-search/json-api/v1/using_rest, You have to give some sites to search, If you didn't provide the sites to search here(https://www.google.com/cse/all), It will not show you the results. At least put one site to search, or many sites to search. Your wanted Google Web Search API has been officially deprecated as of November 1, 2010.
https://developers.google.com/web-search/docs/
It only search entire web
I also faced the same issue,
after research i found that i didnt provide sites in search engine which i created
so i provide www.google.com as a site in search engine page
here is the link to add site in your search engine
https://www.google.com/cse/setup/basic?cx={your search engine id}
after executing above link with your search engine id you will get your search engine page
then go into "Basics" tab in which go into "site to search" section then Add site
for me i used www.google.com
and my issue get resolved :)

Nextpagetoken not working as desired

There are a lot of videos in the channel. Where as 'nextPageToken' only
iterates about 570 of them on my code.
Perhaps not a lib issue because the same happens on https://developers.google.com/youtube/v3/docs/search/list. After about only 10 pages the nextPageToken disappears.
You should using channel+playlistItems API to get ALL channel videos, not search API.
Kindly check it out on https://developers.google.com/youtube/v3/docs/channels/list#try-it.
Example, i set the channel id UCi-Lb1gFer4U7tkqFA1adiQ and part parameter as contentDetails.
the example of response is:
"items": [
{
"id": "UCi-Lb1gFer4U7tkqFA1adiQ",
"kind": "youtube#channel",
"etag": "\"NT-fDeVOLsFPouddIzcaWbd0fJw/sQKRHjGLTreNbWWrW3gIojOKiEk\"",
"contentDetails": {
"relatedPlaylists": {
"uploads": "UUi-Lb1gFer4U7tkqFA1adiQ"
}
}
}
]
Then you know the uploads playlist id now, UUi-Lb1gFer4U7tkqFA1adiQ, so you visit
https://developers.google.com/youtube/v3/docs/playlistItems/list
Put UUi-Lb1gFer4U7tkqFA1adiQ as the playlistId, then you would able to get all the videos by pagination.
p/s: please provide your channel id, if you still experience the problem

Categories