Posts tagged with curl

I am currently creating an application which uploads information to Facebook using the Facebook Graph API. However, I am currently facing an error when trying to initialize an upload session.

When I write the following C-URL:

curl -X POST "https://graph.facebook.com/v21.0/<THE PAGE ID>/video_reels" \     -H "Content-Type: application/json" \     -d '{{            "upload_phase:"start",            "access_token":"<THE ACCESS TOKEN>"         }}' 

I get the error:

{"error":{"message":"Unsupported post request. Object with ID <PAGE ID> does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\\/\\/developers.facebook.com\\/docs\\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"ARVFrHVkhXZTsIN4Lzal-Gb"}} 

I have tried to change the permissions on the Facebook account, but when I refresh the page, nothing has changed. Has anybody got an idea what the problem could be?

I'm trying to create a message template for whatsapp business and i keep getting an error. Following the docs, I think my implementation is correct. If buttons are not included(with dynamic content its pretty much easy on the meta dashboard, but here I'm try to use button with dynamic content which is not possible on the dashboard so I have to go the curl way but it's not working. below is my implementation(had to switch to python thinking i might get on to something)

import requests from requests.structures import CaseInsensitiveDict url = "https://graph.facebook.com/v20.0/whatsapp_busines_id/message_templates" headers = CaseInsensitiveDict() headers["Authorization"] = "Bearer YOUR_ACCESS_TOKEN" headers["Content-Type"] = "application/json" data = """ {         "name": "payment_success_property_contact",         "language": "en",         "category": "UTILITY",         "components": [           {             "type": "HEADER",             "format": "TEXT",             "text": "Payment Successful"           },           {             "type": "BODY",             "text": "Hi there! Great news! Your payment for \"{{1}}\" is successful. Please contact the owner via WhatsApp or normal call to visit and check the property. After your visit, you can confirm or cancel the payment.\n\nEnjoy your visit!",             "example": {               "body_text": [                 "Seaside Villa"               ]             }           },           {             "type": "FOOTER",             "text": "Nanohunt Software"           },           {             "type": "BUTTONS",             "buttons": [               {                 "type": "URL",                 "text": "Contact via WhatsApp",                 "url": "https://wa.me/{{2}}",                 "example": {                   "parameters": [                     {                       "type": "text",                       "text": "YOUR_PHONE_NUMBER"                     }                   ]                 }               },               {                 "type": "PHONE_NUMBER",                 "text": "Call Owner",                 "phone_number": "{{2}}",                 "example": {                   "parameters": [                     {                       "type": "text",                       "text": "YOUR_PHONE_NUMBER"                     }                   ]                 }               },               {                 "type": "URL",                 "text": "Confirm or Cancel Payment",                 "url": "{{3}}",                 "example": {                   "parameters": [                     {                       "type": "text",                       "text": "https://yourwebsite.com/transaction/TRANSACTION_ID"                     }                   ]                 }               }             ]           }         ]       } """ resp = requests.post(url, headers=headers, json=data) print(resp.json()) 

So after running it i get

mbishu@fedora:~/Desktop/nanohuntapi$ python template.py {'error': {'message': '(#100) The parameter name is required.', 'type': 'OAuthException', 'code': 100, 'fbtrace_id': 'AywCoC2brI1L5kRVmtbHD-c'}} 

I search the internet so far but no viable solution

I want to post something in my FB feed wall (not any Page) using graph API. The Permissions:

pages_show_list instagram_content_publish pages_read_engagement pages_read_user_content pages_manage_posts pages_manage_engagement 

User or Page: User Token. Thus I generated the Access Token.

Next I am using the curl:

curl -X POST "https://graph.facebook.com/v20.0/me/feed" \      -H "Content-Type: application/json" \      -d '{            "message": "some msg",            "link": "some link to an image",            "published": "true",            "access_token": "the access token I got as mentioned above" 

And I am getting this error:

 }' {"error":{"message":"(#200) If posting to a group, requires app being installed in the group, and \\\n          either publish_to_groups permission with user token, or both pages_read_engagement \\\n          and pages_manage_posts permission with page token; If posting to a page, \\\n          requires both pages_read_engagement and pages_manage_posts as an admin with \\\n          sufficient administrative permission","type":"OAuthException","code":200,"fbtrace_id":"AT-wsNX19z1oFPFxq0tbLZF"}}%   

What I do not understand about the error message is that I am trying not to post in any group/page, but just my FB feed wall.

But later, I decided to create a Page, and try posting there. The code I used to get the Page is:

url -X GET "https://graph.facebook.com/v20.0/me/accounts?access_token=theaccesstoken >>> [{"access_token":"some access token, I am not sure what this is","category":"Property","category_list":[{"id":"198327773511962","name":"Property"}],"name":"MyTest","id":"394143863782471","tasks":["ADVERTISE","ANALYZE","CREATE_CONTENT","MESSAGING","MODERATE","MANAGE"]}],"paging":{"cursors":{"before":"QVFIUkVZASmx4RXhWemFZAX19pOGZALaTZAfMVJlTUtpaXZALMVlucnZAhVnc4WktZAV1hYUm1JTjE4NW5EOUdCYjRoTGRnLU1xSl9VZAi1qZAy1wbVJ6UWJ1cENHaXRR","after":"QVFIUkVZASmx4RXhWemFZAX19pOGZALaTZAfMVJlTUtpaXZALMVlucnZAhVnc4WktZAV1hYUm1JTjE4NW5EOUdCYjRoTGRnLU1xSl9VZAi1qZAy1wbVJ6UWJ1cENHaXRR"}}} 

I assume that 394143863782471 is the page_id as yes the name of my page is MyTest.

Then I used from here:

curl -X POST "https://graph.facebook.com/v20.0/394143863782471/photos" \      -F "source=@/path to my image" \      -F "caption=some caption" \      -F "access_token=the access token of the app >>> {"error":{"message":"(#200) The permission(s) publish_actions are not available. It has been deprecated. If you want to provide a way for your app users to share content to Facebook, we encourage you to use our Sharing products instead.","type":"OAuthException","code":200,"fbtrace_id":"AWHagdudbcBgpKNO6yPYM73"}}%    

I cannot understand what this error means. Can someone help?

I am trying to use the Graph API to post a link (URL) to a Facebook page, using PHP and the cURL library. I am able to request a scrape with no issues. But when I try to post my URL to the page, I get the error:

(#100) Specifying multiple ids with a post method is not supported 

I believe that I have the correct scopes to post to my page, per the page Access Token:

email public_profile pages_show_list pages_read_engagement pages_manage_posts 

And it's the token for the page I am trying to post to. The URL that I'm pushing through cURL is (URL and MESSAGE are url-encoded):

$request_url =        https://graph.facebook.com/<PAGE-ID>/?id=<URL-TO-POST>&message=MESSAGE&access_token=<PAGE-TOKEN>; 

And I'm using pretty simple curl commands:

$handle = curl_init(); $curl_options = [                     CURLOPT_URL            => $request_url,                      CURLOPT_RETURNTRANSFER => true,                      CURLOPT_VERBOSE        => false,                      CURLOPT_POST           => true,                 ]; } curl_setopt_array($handle, $curl_options); $raw_data = curl_exec($handle); curl_close($handle); 

But the results I get from this call:

[error] => stdClass Object  (     [message] => (#100) Specifying multiple ids with a post method is not supported     [type] => OAuthException     [code] => 100     [fbtrace_id] => Av1ZYcuRG0hNE2KZUl94eEv  ) 

Am I using the correct URL to post? Are there missing arguments?

All the template messages that I post once will be received twice by the opposite user. I send messages through php API. I have two apps under one business account, and both are having the same problems. My PHP curl code is:

$messageBody = 'Welcome and congratulations!! This message demonstrates your ability to send a WhatsApp message notification from the Cloud API, hosted by Meta. Thank you for taking the time to test with us.' ; $template_array = array(     "name" => $templateName, //     "language" => '{ "code": "en_US" }',      //"components" => '' //for parameters ) ; $text_arr = array(     'preview_url' => 'false',      'body' => $messageBody ); $fields = array(     'messaging_product' => 'whatsapp',     'recipient_type' => 'individual',     'to' => 91 . $toMobile,     'type' => 'template',     'template' => $template_array,     'type' => 'text',     'text' => $text_arr ); $headers = array( "Authorization: Bearer " . $accessToken, "Content-Type: application/json", ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $postUrl); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($fields) ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers ); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = json_decode(curl_exec($curl), true); //print_r($response); $jsonResult = curl_exec($curl) ; $resultCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); echo $resultCode . ' - ' . $jsonResult ; curl_close($curl);