Posts tagged with python

I am attempting to create a Facebook posting using Jupyter notebook.

import facebook as fb # Initialize the Graph API with your access token access_token = 'code' graph = fb.GraphAPI(access_token) # Test API call user_info = graph.get_object('me') print(user_info) # Create the post post_message = "testing" graph.put_object(parent_object='me', connection_name='feed', message=post_message) 

However, there is an GraphAPIError: (#200).

In my Graph API Explorer, I have User Token with the following permission: user_events, user_photo, user_videos, user_post, public_profile.

May I know what else am I missing?

I'm working on a small python script to automate a daily post to a page my wife manages. It downloads a pic, merges with a header, and posts to the page with a URL and some text. My idea is ultimately to drop this on a Linux box I have and schedule it to fire once a day. If I do go to automate it, I'm wondering if there's a way to check and make sure the post hasn't already been done. The text is consistent (and unique as it has the date in it). Is there a way to have the script search the page for the text before posting? Searches so far haven't yielded much.

I've encountered an error while attempting to list all first-party audience segmentations created in my GoogleAds account using the googleads Python library. Despite confirming that the credentials are correct and updating the library to the latest version available, I continue to face the following error:

[WARNING] 2024-03-26T12:42:30.368Z 41d1f691-e863-47a7-97c7-4ceec141ccef Error summary: {'faultMessage': '[ServerError.SERVER_ERROR @ ]', 'requestId': '8e056b59b2549571b78c96c177a495e2', 'responseTime': '1173', 'serviceName': 'AudienceSegmentService', 'methodName': 'getAudienceSegmentsByStatement'}

I've even attempted to execute the code on a clean installation in a virtual machine, but the error persists.

I'm reaching out to seek assistance from the community regarding this issue. Any insights or suggestions on how to resolve this error would be greatly appreciated.

Thank you in advance for your help.

Best regards;

I've even attempted to execute the code on a clean installation in a virtual machine, but the error persists.

The credentials are correct.

(1) In the area I am now, Google website is not visitable because of the Great Firewall. But I am using Clash for Windows and I could access and visit Google website. It works well on my browser.

(2)I am testing Google Ads API with simple function in Python like the following through Jupyter Notebook which is installed on my Windows 10 laptop:

import logging logging.basicConfig(level=logging.INFO) from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException    # Define the main function def main(client, customer_id):     ga_service = client.get_service("GoogleAdsService")     query = """         SELECT             campaign.id,             campaign.name         FROM campaign         ORDER BY campaign.id     """     # Issues a search request using streaming.     stream = ga_service.search_stream(customer_id=customer_id, query=query)     # Iterate through the results and print them     for batch in stream:         for row in batch.results:             print(                 f"Campaign with ID {row.campaign.id} and name "                 f"{row.campaign.name}"             ) # Load Google Ads client from storage # Replace "PATH/TO/YOUR/google-ads.yaml" with the actual path to your file googleads_client = GoogleAdsClient.load_from_storage(path=r"C:\Users\tomxi\google-ads.yaml", version="v15") # Get customer ID from user input (optional) # Replace with your desired method of obtaining the customer ID customer_id = "xxxxxxxxxx" # Call the main function try:     main(googleads_client, customer_id) except GoogleAdsException as ex:     print(         f'Request with ID "{ex.request_id}" failed with status '         f'"{ex.error.code().name}" and includes the following errors:'     )     for error in ex.failure.errors:         print(f'\tError with message "{error.message}".')         if error.location:             for field_path_element in error.location.field_path_elements:                 print(f"\t\tOn field: {field_path_element.field_name}")     sys.exit(1) 

(3)I got the error:

[TransportError: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: /o/oauth2/token (Caused by SSLError(SSLEOFError(8, '\[SSL: UNEXPECTED_EOF_WHILE_READING\] EOF occurred in violation of protocol (_ssl.c:1006)')))][1] 

(4)I guess the Google Ads API employs some route or something else which is not used or controlled by the Clash for Window on my laptop. I am not sure how to check and change it. Please help me.