Skip to content

Commit

Permalink
update python and curl examples
Browse files Browse the repository at this point in the history
Have `curl` examples use a $PDSHOST variable instead of hard-coding
https://bsky.social in the examples.

Use handle.example.com instead of example.com.

Use updated/current invocation of python SDK, which doesn't require
entryway URL.
  • Loading branch information
bnewbold committed Oct 2, 2024
1 parent 5156b62 commit 2e5f45f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/advanced-guides/posts.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,4 @@ On Bluesky, each client fetches and embeds this card metadata, including blob up

A complete script, with command-line argument parsing, is available [here](https://github.com/bluesky-social/cookbook/tree/main/python-bsky-post).

We expect most folks will use SDKs or libraries for their programming language of choice to help with most of the details described here. But sometimes it is helpful to see what is actually going on behind the abstractions.
We expect most folks will use SDKs or libraries for their programming language of choice to help with most of the details described here. But sometimes it is helpful to see what is actually going on behind the abstractions.
14 changes: 7 additions & 7 deletions docs/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ Create an authentication session with your username and password.
service: 'https://bsky.social'
})
await agent.login({
identifier: 'example.com',
identifier: 'handle.example.com',
password: 'hunter2'
})
```
</TabItem>
<TabItem value="curl" label="CURL">
Replace `$BLUESKY_HANDLE` and `$BLUESKY_PASSWORD` with your credentials.
Replace `$BLUESKY_HANDLE` and `$BLUESKY_PASSWORD` with your credentials, and `$PDSHOST` with your PDS host (including `https://`).

```bash
curl -X POST https://bsky.social/xrpc/com.atproto.server.createSession \
curl -X POST $PDSHOST/xrpc/com.atproto.server.createSession \
-H "Content-Type: application/json" \
-d '{"identifier": "'"$BLUESKY_HANDLE"'", "password": "'"$BLUESKY_PASSWORD"'"}'
```
Expand All @@ -64,8 +64,8 @@ Create an authentication session with your username and password.
```python
from atproto import Client

client = Client(base_url='https://bsky.social')
client.login('example.com', 'hunter2')
client = Client()
client.login('handle.example.com', 'hunter2')
```
</TabItem>
</Tabs>
Expand Down Expand Up @@ -100,10 +100,10 @@ Now you can create a post by sending a POST request to the createRecord endpoint
```
</TabItem>
<TabItem value="curl" label="CURL">
Replace `$BLUESKY_HANDLE` with your handle and and `$ACCESS_JWT` with the JWT in the response from createSession.
Replace `$BLUESKY_HANDLE` with your handle, `$PDSHOST` with your PDS host (including `https://`), and and `$ACCESS_JWT` with the JWT in the response from createSession.

```bash
curl -X POST https://bsky.social/xrpc/com.atproto.repo.createRecord \
curl -X POST $PDSHOST/xrpc/com.atproto.repo.createRecord \
-H "Authorization: Bearer $ACCESS_JWT" \
-H "Content-Type: application/json" \
-d "{\"repo\": \"$BLUESKY_HANDLE\", \"collection\": \"app.bsky.feed.post\", \"record\": {\"text\": \"Hello world! I posted this via the API.\", \"createdAt\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}}"
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/creating-a-post.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Each post requires these fields: `text` and `createdAt` (a timestamp).
service: 'https://bsky.social'
})
await agent.login({
identifier: 'example.com',
identifier: 'handle.example.com',
password: 'hunter2'
})

Expand All @@ -58,8 +58,8 @@ Each post requires these fields: `text` and `createdAt` (a timestamp).
```python
from atproto import Client

client = Client(base_url='https://bsky.social/xrpc')
client.login('example.com', 'hunter2')
client = Client()
client.login('handle.example.com', 'hunter2')
post = client.send_post('Hello world! I posted this via the Python SDK.')
```

Expand Down

0 comments on commit 2e5f45f

Please sign in to comment.