Posts tagged with php

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?

I created a small script to handle all webhooks from Facebook feed. The goal is to detect when a page goes live and get all comments from that live video. So far, everything is working well: I receive all the necessary information, including comments with the from ID and from Name.

However, I've encountered an issue where the from ID doesn't seem to be correct. If I try to navigate to facebook.com/FROM_ID, I get an error. After fetching some data and comparing it against known user IDs, I noticed they don't match at all. I wonder if this is normal, a bug, or some kind of encryption.

Issue The from ID received in the webhook payload seems incorrect.

Here is an example of the payload I'm receiving:

Array (     [entry] => Array         (             [0] => Array                 (                     [id] => 1xxxxxxxxxxxxxx                     [time] => 1716213862                     [changes] => Array                         (                             [0] => Array                                 (                                     [value] => Array                                         (                                            ** [from] => Array                                                 (                                                     [id] => 1xxxxxxxxxxxxxx                                                     [name] => User Name                                                 )**                                             [post] => Array                                                 (                                                     [status_type] => added_video                                                     [is_published] => 1                                                     [updated_time] => 2024-05-20T14:04:16+0000                                                     [permalink_url] => https://www.facebook.com/MYPAGE/                                                     [id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx                                                 )                                             [message] => Some Random Message                                             [post_id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx                                             [comment_id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx                                             [created_time] => 1716213856                                             [item] => comment                                             [parent_id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx                                             [verb] => add                                         )                                     [field] => feed                                 )                         )                 )         )     [object] => page ) 

Questions

  • Is it normal for the from ID in webhook events to not match the expected user ID format?
  • Is there any encryption or obfuscation applied to the from ID?
  • Has anyone else faced this issue, and how did you resolve it?

Additional Information

Thank you!

Graph API Requests: I tried using the Graph API with the from ID to fetch basic user information but received errors.

Searching for Similar Issues: I searched extensively for similar issues related to Facebook webhooks but couldn’t find any relevant solutions.

I'm using a rich text editor to create social media posts' text and I save it in DB as HTML to keep the format, I want to send these texts to Facebook Graph API formatted for example:

// DB <p>✨ <strong>Discover Elegance Redefined</strong>! Explore the brilliance of this meticulously crafted <em>platinum engagement ring</em>, featuring a stunning <strong>pavé diamond band</strong> that perfectly complements its breathtaking <strong>center stone</strong>. 💍 #ForeverBrilliant #EngagementRing #LuxuryJewelry #DiamondLove ✨</p> 

//FB ✨ Discover Elegance Redefined! Explore the brilliance of this meticulously crafted platinum engagement ring, featuring a stunning pavé diamond band that perfectly complements its breathtaking center stone. 💍 #ForeverBrilliant #EngagementRing #LuxuryJewelry #DiamondLove ✨

I tried to use HTMLPurifier Library but still not working

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); 

I find the Facebook developers API documentation a bit confusing. I'm building a small app using PHP and I would like to fetch/scrape data from a page which isn't belong to me.

is it possible using the API or i will need to scrape the data manually? If it's possible, is it possible if i'm not the owner of the page as well?