Unsupported method, post while using facebook score api - php

My problem is, while i post score using facebook php sdk it alwasys give error as Unsupported method, post.
Here is the code I use:
$app_AccessToken = $obj_facebook->getAccessToken();
$obj_facebook->api('/100003470602309/scores/', 'post ', array('access_token' => $app_AccessToken, 'score' => '154125'));

use some thing like
$obj_facebook->api('/me/scores', 'POST', array( 'score' => 100, 'access_token' => $obj_facebook->getAppId().'|'.$obj_facebook->getApiSecret() ));
try this :p may be it will help

It could be due to access token. Make sure you have an app access token.

Related

Unable to fetch response from file_get_contents using PHP

Gurus,
I am trying to fetch tracking details using the austpost.com.au website for which I have written the below code however, it doesn't seem to fetch anything.
$austpost_url = 'https://digitalapi.auspost.com.au/shipmentsgatewayapi/watchlist/shipments/99702032243801004670904';
$options = array(
'method' => 'get',
'contentType' => 'application/json',
'muteHttpExceptions' => true,
'headers' => array ('Accept' => 'application/json, text/plain, */*',
'Accept-Encoding' => 'gzip, deflate, br',
'AP_CHANNEL_NAME' => 'WEB_DETAIL',
'api-key' => 'd11f9456-11c3-456d-9f6d-f7449cb9af8e',
'Connection' => 'keep-alive',
'Origin' => 'https://auspost.com.au',
'Referer' => 'https://auspost.com.au/mypost/track/'),
);
$context = stream_context_create($options);
$html = file_get_contents($austpost_url, false, $context);
echo $html;
Direct Tracking Link: https://auspost.com.au/mypost/track/#/details/99702032243801004670904
I found this by going to the NETWORK tab in Chrome and figured out which request is loading the tracking details. Basically I am just after getting the status of the shipment. Snapshot below:
Any help in this would be much appreciated as I am using PHP to drive my code where I want to update the WordPress posts statuses based on the shipment status (that I can handle) however, stuck here on how I can get this shipment status before I move on.
It is because you need a valid recaptcha token and proof that you are not a robot. Won't be that simple, as you think. The easiest, but paid method, would be to use some captcha solving companies, like https://2captcha.com (not a sponsor of that answer) and their PHP libs.
If you want to use their api, you need to auth with username and password via basic auth. More details in here: https://developers.auspost.com.au/apis/shipping-and-tracking/reference/track-items
First check the fopen is on or off , add the phpinfo(); code in main file and check this .
Otherwise use the Curl function instead of file_get_contents();

Writing library for Twitter, where am I going wrong?

I'm writing a library to connect to Twitter that uses Requests for PHP. I'm not sure, but I don't think that I'm building the OAuth correctly because I can't authenticate. I've double-checked it, and checked it against another existing library but still can't seem to get it right.
The code is here.
The idea is you instantiate the service, send it config parameters, and before it does the request, it generates the 'Authorization: OAuth xxx' header and adds it to said request.
$twitter = array(
'consumer_key' => '',
'consumer_secret' => '',
'access_token' => '',
'access_token_secret' => '',
'screen_name' => '_hassankhan',
'api_url' => 'https://api.twitter.com/1.1/'
);
$service = new OAuth1AService('Twitter', $twitter['api_url']);
$service->config($twitter);
$service->doGet(
'statuses/user_timeline.json',
array(
'screen_name' => '_hassankhan',
'include_entities' => 'true'
),
array(),
'raw'
);
print($service->getResult());
I would really recommend you to use one of the already made libraries like tmhOAuth which make it really easy to interact with the twitter api.
As for your problem, seems you don't sign your request correctly. At least I could not easily find out if you include all request parameters to create the signature.
The oauth_signature parameter contains a value which is generated by
running all of the other request parameters and two secret values
through a signing algorithm.
Creating the signature is described in this document: https://dev.twitter.com/docs/auth/creating-signature .

Facebook PHP SDK post activity

I am trying to post to a users Activity feed on Facebook using the PHP SDK, is this possible? Or only with Javascript?
Here is my basic code to post to a users wall:
$facebook->api('/me/feed', 'POST',
array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!'
));
I want to post to a users activity, how is this done? I've experimented with the code below but to no success.
$facebook->api('/me/application:view', 'POST',
array(
'item' => 'www.example.com',
));
Can anyone shed any light on this?
I'm not using opengraph in my apps right now, but hope this helps:
https://developers.facebook.com/docs/opengraph/tutorial/#publish
Also check this answer (there is an example in PHP):
https://stackoverflow.com/a/11383901/173299
Hope it helps you.

how to add share action to the post in facebook?

i'm using this code to post to my application wall
$attachment = array('message' => 'xxxxxxxxxxxxxxxx...',
'name' => 'xxxxxxxxxxxxxxxxxxx',
'caption' => 'xxxxxxxxxxxxxxxxxx',
'link' => 'xxxxxxxxxxxxxxxxxx',
'description' => 'xxxxxxxxxxxxxxxxxx',
'picture' => 'xxxxxxxxxxxxxxxxxx',
'actions' => array(array('name' => 'Download!',
'link' => 'xxxxxxxxxxxxxxxxxx'))
);
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
when i post to my application wall manually the post is appearing on the application users wall with the share action
but when i use the above code it only appear on the app wall with like and comment actions only.
why?
and how to add the share action to the actions array?
i didn't find any answer online, but i just found the solution to my problem by chance
i removed the action parameter from the attachment.
but if there is a link parameter in the attachment the share action won't appear so you will have to give up the link parameter.
the proper names for the action link is:
array( array('text' => 'Download!', 'href' => 'xxxxxxxxxxxxxxx'));
Keep in mind that you can't use action links in the graph api (yet). so this functionality is limited to the REST api.
Let me know if this helps
http://facebookanswers.co.uk/?p=270
This article explains it. The key is this:
'actions' => array('name'=>'Sweet FA','link'=>'http://www.facebookanswers.co.uk'),
This is fine for adding one action. However, I'm not sure how to add two.
Hi the solution is here
instead of
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
use
$result = $facebook->api('/2222222222222/links/','post',$attachment);
i'm still facing one little problem with the picture not showing after this change, if i come to a solution to it I'll come back here and post it.

Update facebook status using php

I know it's a very old question.But i really bound to ask the same question again.How can i update my status using PHP?Because i find several solutions in google and stackoverflow but non of that currently works.May be the cause of facebook up gradation process or anything else.
I chk:
1) http://360percents.com/posts/php-curl-status-update-working-example-sep-2010/
2) http://www.barattalo.it/2010/03/01/php-curl-bot-to-update-facebook-status/
But unfortunately non of the solution is working.So, is their any kind heart who can help me to update the facebook status using php easily?i shall be very much glud if anybody pls give any working solution. Regards---riad
Well, I've wrote a tutorial about posting to the user's wall: How To: Post A Message On The User Wall Using Facebook Graph API.
$args = array(
'message' => 'Hello from my App!',
'link' => 'http://www.masteringapi.com/',
'caption' => 'Visit MasteringAPI.com For Facebook API Tutorials!'
);
$post_id = $facebook->api("/me/feed", "post", $args);
Notes:
I'm using the PHP-SDK
You need the publish_stream permission
Check out this answer
What about checking directly the Facebook API ?
http://developers.facebook.com/docs/
Check the "Graph API"
The Graph API is the core of Facebook Platform, enabling you to read and write data to Facebook. It provides a simple and consistent view of the social graph, uniformly representing objects (like people, photos, events, and pages) and the connections between them (friendships, likes, and photo tags).
I wrote this code im my blog completely pl check that in the following link
http://scriptime.blogspot.in/2012/12/facebook-status-updates-using-php-sdk.html
here i am giving samll code
$status = $_POST['status'];
$facebook_id = $userdata['id'];
$params = array(
'access_token' => $access_token,
'message' => $status
);
$url = "https://graph.facebook.com/$facebook_id/feed";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));

Categories